You are on page 1of 2

! UNIX/LINUX QUICK COMMAND REFERENCE GUIDE !

UNIX/LINUX QUICK COMMAND REFERENCE GUIDE

File Commands System Info


ls list directory contents man command format and display the on-line manual pages for command command

ls -al formatted listing with hidden files date show the current date and time

cd dirname change directory to dirname cal show this months calendar

cd go to user home uptime show current uptime

cd .. go back one directory w display who is login

pwd show current directory name whoami display who you are logged in as

mkdir dirname create directory dirname finger user display information about user

rm filename delete file filename uname -a show operating system kernel information

rm -r dirname delete directory dirname cat /proc/cpuinfo cpu information

force delete file filename


rm -f filename cat /proc/meminfo memory information
USE WITH EXTREME CAUTION
force delete directory dirname
rm -rf dirname df show disk usage
USE WITH EXTREME CAUTION

cp filename1 filename2 copy file filename1 to file filename2 du show directory space usage

copy directory dirname1 to directory dirname2; create directory dirname2 if it


cp -r dirname1 dirname2 free show memory and swap usage
does not exist
rename or move file filename1 to file filename2. If file filename2 is an existing
mv filename1 filename2
directory, moves file filename1 into directory filename2

ln -s filename linkname create symbolic link linkname to file filename SSH


ssh user@host connect to host as user
touch filename create file filename or change file access and modification times of file filename

ssh -X -l user host connect to host as user, with X11 forwarding


cat > filename places standard input into file filename; concatenate and print files

more filename output the contents of file filename secure copy (remote file copy program)
Examples:
Copying file to host:
head filename output the first 10 lines of file filename scp source host:target
scp sourcefile user@host:directory/targetfile
scp host:target source
Copying file from host:
tail filename output the last 10 lines of file filename scp user@host:directory/sourcefile targetfile
scp -r user@host:directory/sourcefolder targetfolder

tail -f filename output the contents of file filename as it grows, starting with the last 10 lines

! 1 ! 2
! UNIX/LINUX QUICK COMMAND REFERENCE GUIDE ! UNIX/LINUX QUICK COMMAND REFERENCE GUIDE
File Permissions Compression/Installation
change the permissions of file to octal, which can be set separately for user, group, and tar cf file.tar files create a tar file named file.tar containing files
world by adding:
4 read (r) tar xf file.tar extract the files from file.tar
2 write (w)
chmod octal file
1 execute (x)
Examples: tar czf file.tar.gz files create a tar file with gzip compression
chmod 777 read, write, execute for all (owner, group and world)
chmod 755 rwx for owner, rx for group and world tar xzf file.tar.gz extract a tar using gzip

tar cjf file.tar.bz2 create a tar with bzip2

Process Management tar xjf file.tar.bz2 extract a tar using bzip2

ps display your currently active processes


gzip file compresses file and renames it to file.gz

top display all running processes


gzip -d file.gz decompresses file.gz back to file
kill process id pid
kill pid
USE WITH EXTREME CAUTION dpkg -i pkg.deb install a package (debian)
kill all proceses named proc
killall proc
USE WITH EXTREME CAUTION rpm -Uvh pkg.rpm install a package (RPM)

bg lists stopped or background jobs; resume a stopped job in the background


git clone git://domain clone a file/directory using git

fg brings the most recent job to foreground


git pull update a file/directory using git

fg n brings job n to the foregorund

htop Executes interactive process viewer (if it is installed)


Network
ping host ping host and output results

Searching whois domain get whois information for domain

grep pattern filename search for pattern in filename


dig domain get DNS information for domain

grep -r pattern dirname search recursively for pattern in dirname


dig -x host reverse lookup host

command | grep pattern search for pattern in the output of command


wget file download file

locate filename find all instances of filename


wget -c file continue a stopped file download

which command locate a command command

find dir -name pattern search for pattern in a directory hierarchy


Text Editing
whereis command show possible locations of command vi file use text editor vi to edit file file (no GUI)

gedit file use text editor gedit to edit file file (GUI)

! 3 ! 4

You might also like