Linux Commands
This is a list of Linux codes, I put together for all of you who love to thinker with Linux machines. Enjoy!
Invoking vi
Vi (type the letter vi and the name of file you want to create)
Two basic input commands
I insert text to the left of the cursor
A append text to the right of the cursor
Esc ( end insertion and return to command mode)
Cursor movement commands
H move the cursor one space to the left
J move the cursor one space down
K move the cursor one space up
L move the cursor one space to the right
Deleting text
X delete the character at the cursor
DD delete a line
File saving
:w save (write to disk)
:q exit
:q! to start all over
Granting Unix Permissions
Ls –l (list all files in your home directory)
-rw-r–r– 1 e-huss usr 123339 Jun 7 10:41 getstats_12.c
-rwx—— 1 e-huss usr 103316 Jul 15 00:04 hexpert
-rw——- 1 e-huss usr 32768 Jul 15 00:03 hexpert.tar
-rwx—— 1 e-huss usr 10056 Sep 25 18:46 htpasswd
-drwx——6 e-huss usr 512 May 15 12:31 Java
-rw——- 1 e-huss usr 22768 Oct 15 17:32 siggraph.jpg
-rw——- 1 e-huss usr 1312180 Sep 15 11:53 siggraph.tiff
-rw——- 1 e-huss usr 373760 Aug 29 20:27 unz512x.tar
Cat >filename
File type User
{-Rwxrwxrwx}
- Group World
Ctrl D (edite file)
Using: apropos, whatis and man commands
$ apropos tape (pull all commands with the word tape in the CLI)
$ apropos content (locate name of a command that list directory content) ex: ls or dir
$ whatis mt ( define what mt does, in brief description)
$ man command ( define what mt does, in a full manual page)
/usr/sbin/ifconfig-2 (to find IP)
/usr/sbin/prtconf-v (to find out memory)
/usr/platform/sun4u/sbin/prtdiag
Ip stat –t (print server status)
/usr/ucb/shutdown +time or halt
/etc/netmasks} update both for
/etc/hosts } I.P. network chg
Prtpost w fnw | prw-pw printername
/usr/platform/sun4u/sbin/prtdiag
Stty erase (intended key-example backspace)
/cognition/colortable
/Axy /colors.M
Ypcat aliases / grep I name filename
Set file ypwhich –who’s
Bound to who
Ypcat w file name
Ypcat w ypservers
Cd /net/mercury/local/doc/wksta/hdware/net/cables/patch –pa
Cd /net/mercury/local/data ls
/mercury/net/local/maint/printer.install
Usar login name (to get users system)
Su setenv EDITOR vi crontab –e (edits, 2C, -1)
30 1 * * * /usr/sbin/reboot
Ps –ef | grep ‘\-c’
Ideas_| remove
Cqmtoepsi -CADleaf
To restore files using Q.R
1. Date
2. filename
3. location old file
4. new location of new
.cshrc edits for alias: alias: alias l ‘ls la’
Sort +1 -2 filename –sorts by second field
Cd /var/adm/more message ERRORS & boot msqs
Sort –k 1.1b assets sort file by 1st non blank char
File core –to find out where it came from.
/usr/sbin/psrinfo –v (to check CPU status)
Cdg lp –p ps3 fn (to print cdg pg3d pg3l pbl sided 11*17
To move dir of file across file systems
/home/m1/ochoa/junk /home/m2/ochoa/junk
(cd /home/m1/ochoa ; tar.cvf –junk) | (cd /home/m2/ochoa; tar.xvf –)
To save a mail message
File::> mail files :::> select path & filename
Grep –l 400 * (finds string 400 in files located in ‘.’ And prints filename).
/usr/sbin/ufsdump ouf /dev/rmt/0cn (fs) :set nu
Line# wG
Notes user ID#: 6C3A DF04 ADBD 5761 6924 924CCF4801FB
Mail-s “subject name” recipient_e-mail < files cat.cshrc | mail recipient_e-mail
/apps/bin/enscrpt –GP printername filename
(Makes sure all text wraps when printing in unix)
Netstat –nr run as root
(it show the net maps)
(to delete all files older than 30 days: (all 1line))
Find . \(-name ‘*’ \) –atime +30 –exec rm {} \;
When lot o’ big files are to be tarred,
Cd to dir above the one containing the files
Tar cvf filename.tar filename ( ./filename wont hurt)
Tar xvf /dev/rmt0
Du -s * | sort –nr
Delhi 5
Understanding Unix permission and chmod
Chmod 701 filename .html (filename_html)(give users the minimum permission rwx—–x)
Chmod 664 filename.html (this change the permission of the file.namehtml to rw-rw-r–)
Chmod a+r filename.html (the permission for all to read it rwx–r—)
Chmod o+r some_document.html (set permission correctly)
Chmod 604 some_document.html ( set your permission to rw—-r–)
Chmod a-x filename.html (–rw-r—r–)
Chmod g-w filename.html (-rw-rw-r–)
Chmod ug+x filename.html (-rwxrwxr–)
(Ls –l filename.html)
Chmod ug-wx filename.html (-r- -r- -r–)
Chmod u=r another_example.html (permission change so the user can only read it r——–)
Who – who specifies which permission group we are changing. Possible values are:
U – user’s permission
G – group’s permission
O – other’s permission
A – all permission (user, group, and other)
Operator – specifies which action to take. Possible value are:
+ - add the permission
- _- removes the permission
= - sets the permission exactly
Permissions – specifies which permission bit to change. The ones we are concerned with are:
R – the read bit
W – the write bit
X – the execute bit
Cd (change directory)
Cd filename_html (make changes to your filename_html directory)
Mkdir
Mkdir filename_html (will make a new directory called filename_html)
Rm
Rm filename.html (will remove filename.html)
Rmdir
Rmdir filename_dir (will remove the directory filename_dir as long as it is empty)
Man
Man ls (will grab the manual page for the command ls)