Unix/Linux Command Reference

[Pages:4]Unix/Linux Command Reference

File Commands

1. ls 2. ls -al 3. ls -lt 4. cd dir 5. cd 6. pwd 7. mkdir dir 8. cat >file 9. more file 10. head file 11. tail file 12. tail -f file

13. touch file 14. rm file 15. rm -r dir 16. rm -f file 17. rm -rf dir 18. cp file1 file2 19. cp -r dir1 dir2 20. mv file1 file2

21. ln -s file link

Process management

1. ps 2. top

Directory listing Formatted listing with hidden files Sorting the Formatted listing by time modification Change directory to dir Change to home directory Show current working directory Creating a directory dir Places the standard input into the file Output the contents of the file Output the first 10 lines of the file Output the last 10 lines of the file Output the contents of file as it grows,starting with the last 10 lines Create or update file Deleting the file Deleting the directory Force to remove the file Force to remove the directory dir Copy the contents of file1 to file2 Copy dir1 to dir2;create dir2 if not present Rename or move file1 to file2,if file2 is an existing directory Create symbolic link link to file

To display the currently working processes Display all running process

Unix/Linux Command Reference

3. kill pid 4. killall proc 5. pkill pattern 6. bg

7. fg 8. fg n

File permission

1. chmod octal file

Kill the process with given pid Kill all the process named proc Will kill all processes matching the pattern List stopped or background jobs,resume a stopped job in the background Brings the most recent job to foreground Brings job n to the foreground

Change the permission of file to octal,which can be found separately for user,group,world by adding,

? 4-read(r) ? 2-write(w) ? 1-execute(x)

Searching

1. grep pattern file 2. grep -r pattern dir 3. command | grep

pattern 4. locate file 5. find . -name filename

6. pgrep pattern

Search for pattern in file Search recursively for pattern in dir Search pattern in the output of a command

Find all instances of file Searches in the current directory (represented by a period) and below it, for files and directories with names starting with filename Searches for all the named processes , that matches with the pattern and, by default, returns their ID

System Info

1. date 2. cal 3. uptime 4. w 5. whoami

Show the current date and time Show this month's calender Show current uptime Display who is on line Who you are logged in as

Unix/Linux Command Reference

6. finger user 7. uname -a 8. cat /proc/cpuinfo 9. cat proc/meminfo 10. man command 11. df 12. du 13. free 14. whereis app 15. which app

Display information about user Show kernel information Cpu information Memory information Show the manual for command Show the disk usage Show directory space usage Show memory and swap usage Show possible locations of app Show which applications will be run by default

Compression

1. tar cf file.tar file 2. tar xf file.tar 3. tar czf file.tar.gz files 4. tar xzf file.tar.gz 5. tar cjf file.tar.bz2 6. tar xjf file.tar.bz2 7. gzip file 8. gzip -d file.gz

Create tar named file.tar containing file Extract the files from file.tar Create a tar with Gzip compression Extract a tar using Gzip Create tar with Bzip2 compression Extract a tar using Bzip2 Compresses file and renames it to file.gz Decompresses file.gz back to file

Network

1. ping host 2. whois domain 3. dig domain 4. dig -x host 5. wget file 6. wget -c file

Ping host and output results Get whois information for domains Get DNS information for domain Reverse lookup host Download file Continue a stopped download

Unix/Linux Command Reference

Shortcuts

1. ctrl+c 2. ctrl+z

3. ctrl+d 4. ctrl+w 5. ctrl+u 6. ctrl+r 7. !! 8. exit

Halts the current command Stops the current command, resume with fg in the foreground or bg in the background Logout the current session, similar to exit Erases one word in the current line Erases the whole line Type to bring up a recent command Repeats the last command Logout the current session

Unix/Linux Command Reference

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download