You are on page 1of 3

Linux Survival Guide

This guide contains descriptions of the most important Linux commands, commands for the editor vi as 
well as a few funky features.  These commands will be sufficient for you to successfully develop, edit and 
execute the projects for CS214. This is not a Linux tutorial! The idea is for you to set aside an hour – that 
and a bit of curiosity is all it will take for you to become familiar with Linux ­ and try out these commands 
before you start typing your programs. Enjoy!

General

The format of Linux – or, in general Unix – commands is

<command> <options> <arguments>

On­line help with every available command can be looked up by typing

man <command>

User Manipulation

whoami print the name of the owner of the current home directory
passwd change the password for the current home directory
exit leave the current shell

 
File Manipulation

chmod change the file permissions of a file
              mv  rename a file in the current directory or move it under its 
original name to a different directory
cp copy a file 
more display a file on the screen on page at a time
vi interactive text editor
rm remove a file (careful!!!)

Directory Manipulation

ls print a listing of the current directory
cd return to the user home directory
cd ..  move one level up in the hierarchical directory structure
cd  change your current directory
pushd    save the current directory on the directory stack and change
your current directory
popd pop the top­most directory name from the directory stack and
make it your current directory
pwd  print current working directory
mkdir  Create a subdirectory in the current directory.

Process Manipulation

<Ctrl> z suspend the current processing
bg run the currently stopped process in the background
fg resume execution of the currently stopped process in the 
foreground
ps show a list of currently running processes
kill kill a process

Funky Stuff

!! repeat the previous command
!$ use the argument of the previous command to execute the 
current command
| use the output of the first command as input to the second
command, etc (piping) 
<, > take input from a file instead of from standard input, save 
the output in a file instead of on standard output
history show a history of the commands of this current session
grep print lines matching a pattern
!num repeat command number num

vi Commands

i enter insertion mode
<Esc> leave insertion mode
up, down, left, right arrow navigation within filename
<d> [num] <space> delete [num] character(s) at current cursor position
<d> [num] <w> delete [num] word(s) at current cursor position
<d> [num] <d> delete [num] lines at current cursor position
u undo previous command(s) 
:w save filename
:wq save file and quit vi
:q! quit vi without saving changes
:help on­line assistance

You might also like