UNIX COMMANDS CHEAT SHEET
Command Example Description
1. ls ls Lists files in current directory
ls -alF List in long format
2. cd cd tempdir Change directory to tempdir
cd .. Move back one directory
cd ~dhyatt/web-docs Move into dhyatt's web-docs directory
3. mkdir mkdir graphics Make a directory called graphics
4. cp cp file1 web-docs Copy file into directory
cp file1 file1.bak Make backup of file1
5. rm rm file1.bak Remove or delete file
6. mv mv old.html new.html Move or rename files
7. man man ls Online manual (help) about command
8. head head file1 Display the first 10 lines in a file
head -100 file1 Display the first 100 lines in a file
9. tail tail file1 Display the last 10 lines in a file
tail –f file1 Display the contents of the file as it
grows, last 10 lines at a time.
10. less more index.html Look at file, one page at a time
11. more less index.html Look at file, one page at a time
12. cat cat index.html Print on the standard output
cat file1 file2 Concatenate files
13. grep <str><files> grep "bad word" file1 Look for occurrence of a certain pattern
in a file
14. chmod <opt> <file> chmod 644 *.html Change file permissions read only
chmod 755 file.exe Change file permissions to executable
15. ps <opt> ps aux List all running processes by #ID
ps aux | grep dhyatt List process #ID's running by dhyatt
16. kill <opt> <ID> kill -9 8453 Kill process with ID #8453
17. history history Lists commands you've done recently
18. top top Print system usage and top resource
hogs
19. pwd pwd Print name of current/working directory
20. gzip <file> gzip bigfile Compress file
gunzip bigfile.gz Uncompress file
21. tar <file> tar -cf subdir.tar subdir Create an archive called subdir.tar of a
tar -xvf subdir.tar directory
Extract files from an archive file
22. ln –s <file> link ln –s file link Create symbolic link, link to file
23. df df –h Show disk space in human-readable
format
24. du du Show directory space usage
25. nohup <command> nohup cp file1 file2 Run a command immune to hang-ups,
26. <command> & nohup cp file1 file2 & Run a command in the background
27. ssh <user@host> ssh
[email protected] Connect to host as user
28. wget <url/file> wget http://seq.edu/file Download file from valid url
29. scp scp
[email protected]:file1 Secure copy a file from one host to
[email protected]:file2 another
Collected from http://www.tjhsst.edu/~dhyatt/superap/unixcmd.html