UNIX / Linux commands

By: David Rincon

apropos cron Find manual pages mentioning cron.
cat filex List contents of file filex to screen.
cat fileX > filey Overwrite contents of filey with fileX.
cat filex» filey Append contents of filex to filey.
cd /usr Change current directory to /usr.
cd .. Change current directory to previous higher directory.
cd Change to home of current userid.
chgrp group 1 filex Change group id to group 1 for filex.
chgrp R group 1 * Change group id of all files in current and subdirectories to group 1.
chmod ugo+rwx filex Add read/write/execute permission to filex for user/owner, group and others (world).
chmod ox filex Remove execute from others (world).
chmod 751 filex Set rwx for user/owner, rx for group and x for others. rwx=421, r=4, w=2, x=1 rx=5 rwx=7 x=1.
chown sam filex Change owner of file filex to sam
chown R sam  Change owner to sam for all files in current and subdirectories.
clear Clear the terminal screen
compress filex Compress file filex.
cp filex filey copy file filex to filey destroying filey.
cp i */usr/local/bin Copy all files in current directory to /usr/local/bin directory. Prompt before overwriting files (i).
cpio Copy file archives to disk/tape
crontab e Edit crontab file for userid.
crontab e bill Edit crontab file for user bill.
crontab I List crontab entries for current userid.
csh Start the c shell process
cut d: f1,5 /etc/passwd Extract usernarne & real names from file /etc/passwd where delimiter is colon getting fields 1 & 5.
who I cut d” ’11  List login names from who command.
date Display current date string.
date +%D Display current date as 11/21/94 format.
dd Copy file(s) to/from raw devices
df Display free disk blocks and inodes on tie systems. df k Display free space in kilobytes for mounted file systems.
echo name Displays literal “name” on screen.
echo $PATH Displays PATH environment variable
env Displays current environment variables or allows setting.
file filex Determines and displays type of file for filex (text, data, executable, directory, symbolic link…etc…)
find . name “filex*” print Starts searching in current directory for any files starting with filex. If found prints the full file names. Continues searching through
subdirectories.
find/usr/opt/bin -name “filex*” print Starts searching in /usr/opt/bin for files starting with filex.  If found prints the full file names. Continues searching subdirectories.
finger sam Displays data about user session for sam.
ftp target_site Establishes a File Transfer Protocol session over the network between current host and a host named target_site.
grep “drincon”/etc/passwd Searches the file /etc/ passwd searching for string “drincon”.  If found, displays.
grep i “SaM” filex Search filex for upper/lower case string of sam and display any lines found.
groups sam List groups that sam is a member of.
head filex Display first few lines of filex.
head -50 filex Display first fifty lines of filex.
id List current user id and any group ids.
kill -9 666 Terminate process number 666
ksh – start Korn Shell command interpreter.
ln -s filex/usr/opt/filey Create a symbolic link named /usr/opt/filey that points to filex
lpstat -d Displays name of default printer, if any
lpstat -a Displays list of printers accepting print requests
lpstat -s Displays just about everything regarding printing Ipstat -u sam Displays status of sam’s print jobs.
ls -a! Displays all files in wide listing for current directory.
ls -al *.doc Displays files ending with .doc in current directory.
ls -a! /bin/k* Displays files starting with “K’ in /bin directory.
mail sam Starts mail message to sam.
mailx sam Nicer looking mail utility.
make Sophisticated code compilation utiliy.
man who Display online manual pages for who command.
mkdir dirx Creates directory dirx below current directory.
mkdir -p /usr/opt/dirx Creates dirx below /usr/opt.
more filex Displays single pages from filex pausing after each page.
newgrp group1 Changes your current group to group 1.
news Displays unread files from /usr/news or /var/news.
nice/renice Adjusts the execution priority of a process.
page Similar to more command.
passwd Allows changing your login password.
pg Similiar to more and page command.
ps Lists all of current user’s processes that are executing.
ps -ef List all users processes that are executing.
pwd Displays current working directory you are in.
rcp filex hostb:/usr/local/bin Copies filex from current
host system to hostb, and places it in the fusr/local/bin directory. The .rhosts or hosts.equiv files must be setup to allow action.
rksh Starts restricted Korn Shell session.
rlogin hostb Starts a login to remote host name hostb.
rm filex Deletes filex from the disk without recourse.
rm   filex Deletes filex after prompting for verification.
rmdir dirx Deletes directory dirx.
rmdir -r dirx Deletes directory and all contents.
rsh A restricted version of the Bourne Shell for security.
sar System Activity Reporter
sed Stream editor.
sh Bourne Shell command interpreter. Alternative to Korn Shell and C shell.
sleep 3 Pauses for 3 seconds before executing next cmd.
stty sane Attempts to restore terminal settings.  Use CTRL-J with this command.
stty erase AN Use to reset backspace/delete.
su sam Logs you on as user sam after password prompt. su – sam Log on as sam, and execute his .profile too.
tail filex Display last few lines of filex.
tail -50 filex Display last fifty lines of filex.
tar -cvf/dev/rmt/Oc/usr/binr Tape archive utility. Copies all files in /usr/bin directory to tape device /deY/rmV0c.
tar -xvf/dev/rmt/Oc/usr/bin/ Extracts all file from tape device /dev/rmt/Oc and writes them to /usr/bin/.
tar-tvf/dev/rmt/Oc Read tape on device idev/rmt/Oc and lists contents in verbose mode.
tee Used in scripts to split output to two outputs.  Usually used with a pipe command (I). tee -aftrnp/filex
telnet hostb Create a remote terminal onhostb.
touch filex Creates an empty file named filex.
uname -a Lists 0/S revision, host name, hardware info.
uncompress filex Uncompresses file with .Z suffix,
created by compress command previously.
uptime Displays current time, time logged-in, # of users etc.
users Displays current logged-in users in a listing.
uucp Unix-to-Unix Copy utility.
view filex A read only version of vi editor.
w Combination of uptime, who and ps -a commands.
wall Write to all. Allows you to enter a msg to be sent to line 25 of all terminals.  End message with a CTRL-D command.
wc -/ filex Utility that counts the number of lines in filex.
wc -c filex Utility that counts the number of characters in filex.
wc -w filex Utility that counts the number of the words
in filex.
whence filey Prints path name location of executable filey.
which filey Similiar to whence command.
who -r Displays current system run level.
who -b Displays date/time of last reboot.
who am I Displays effective user id of user.
whoami Prints effective username.
vi filex Preferred screen editor for files.

VI Editor
vi filex screen editor for files.

Cursor Movement
h,j,k,l are left, down, up and right movement. 0,$ Jump to front, end of line.
w skip to next word.
CTRL-D Down one page.
CTRL- U Up one page.
G Skip to end of file.
1G Skip to top of file.
CTRL-R or CTRL-L Refresh screen. Searching
/text Search forward for text. ?text Search backward for text.
n Repeat search after find.
Line Numbering
CTRL-G Display current line number :99 Move to line number 99
inserting Text
a Append after cursor.
A Append to end of line.
i Insert before cursor.
I Insert at beginning of line.
o Open new line below cursor.
ESC Terminate edit mode return to command mode.
Changing Text
cw Change word.
cc  Change whole line.
C  Change text to end of line.
dd  Delete line
5dd  Delete current line and next 4.
D  Delete to end of line.
u  Undo last change.
U  Restore current line. Moving Text
yy Yank a copy of current line.
p  Insert the previously yanked line.
Saving and Exiting
ZZ  Save and exit file. :wq  Same as ZZ.
:q!  Exit without saving.
:n  Go to next file to be edited.
:w filex  Save edited file as filex.

Start a conversation about Managed Services

  • We provide a personalized experience
  • Thought & strategic leadership is included for all our clients
  • Flexible arrangements working on-site or remote
  • Boutique services, so that you don’t pay for services you don’t need
  • One-on-one support & training for your staff
  • We provide you with expert-level resources with real world experience

NEXT STEPS – (888)-429-5322