You are on page 1of 6


1. PWD =present working directory 2. . = current directory -E.G = cd . 3. .. = previous directory -E.G = cd .. 4. To Make new_file = touch new_file 5. To make new_dir = mkdirnew_dir 6. To move new_file to new_dir = mv new_filenew_dir 7. Copy the file backout -Go to the directory from where u want to copy back then -E.G = cpnew_file 8. Change directory to desktop = cd desktop/ 9. To remove the new_file from new_dir = rmnew_dir/new_file 10. To remove the new_dir= rm r new_dir 11.To edit new_file = katenew_file If kate has not been installed, try: sudo apt-get install kate 12. To list directories = ls

13.wc = print newline, word, and byte counts for each line -E.G. To Know Total Files in pwd =ls a | wcl -Total files in pwd= ? 14. . at the beginning of a filename means = hidden file 15. new_file~ means = backup file of new_file 16. To know total lines in file = wc l new_file 17. To know total words in file = wc w new_file 18. To know total characters in file = wc c new_file 19. To know how many lines have the word over in file E.G = grep over new_file | wc l 20. To know how many lines have no apostrophe () E.G = grep v new_file | wc l 21. To create symbolic link for any file E.G = touch abc ln s abcnew_link 22. To know what file systems are currently mounted =df 23. h means = print sizes in human readable format 24. To rename fileA to fileB = E.G touch fileA - mvfileAfileB 25.To create directory with space between my file = mkdir my file

26. To copy contents from /media/disk/music to new directory with space between E.G cp r /media/disk/music/* my file 27. Remove the directory with space between = rm r my file 28.View a list of the files, along with their sizes and ownership information, in the /etc directory = ls l /etc 29.Find How many files beginning with the letter b are in the /var/lib directory. E.G ls d ./b* | wc l ls | grep ^b | wc l 30. How much disk space is being used on each currently mounted disk = df h 31. Ensure all of the files in the /bin directory are executable. E.G(1) cd /bin ls ls l E.G(2) sudochmoda+x/bin 32.Create a file named nosmoke in your home directory of size 100k. E.G dd if=/dev/zero of=~/nosmokebs=1024 count=100 33.Determine how many files are in the tar file home-backup.tar. E.G tar t home-backup.tar | wc l 34. Display manual for ls command = man ls 35.Add this line to the end of over.txt (echothis is the last line of the file) E.G echo echoechothis is the last line of the file >> over.txt >> = APPEND LINE

> = OVER WRITE LINE 36.Append the contents of fileB to the end of fileA = cat fileB>>fileA 37. Find out your ip address E.G ifconfig -For only ip address = ifconfig a | grepinet | head -1 38.Determine the process that is using the most CPU time on your system. E.G top (it show process time dynamically refreshes every 2 or 3 seconds) top n1 | head -10 top n1 | head -10 | tail -1 39. Display current date E.G date+%y:%m:%d 40. Display current time E.G date+%h:%m:%s 41. Link the file ~/home/.scripts/shrinkjpg to the /usr/bin directory E.G ln s ~/home/.scripts/shrinkjpg /usr/bin 42. Find all files in all subdirectories on the computer that end with .txt and display their contents. E.G find / -name *.txt exec cat {} \; 43.To get root access or full privileges type : sudosu - If u dont have root access then enable the root account - E.G sudopasswd root - To disable root account - E.G sudopasswd l root

44. Execute a command as part of another command using backward quotes ` back tick is usually above the Tab Key on the keyboard. - E.G echo It is `date +%h:%m:%s` and `date +%d:%m:%y` right now 45.Find file with specified permissions - E.G find .-perm / x - It will find all file which are executable (x = executable) 46.Opens the file file1.txt and searches for the word 'scripts' and replaces every occurrence with the word 'javascript'. -E.G -sed 's/scripts/javascript/g' file1.txt 47.To cut fields in directory field and display file size and file name fields. -E. G ls l | cut d f5,9 48.Wget o | sed e s/Microsoft/Ubuntu/g >outfile - Microsoft word is replaced with Ubuntu 49.To assign a variable and display it. -E.G(1) myvar=this is my variable echo $myvar -E.G(2) a=22 echo $a 50.To print all lines containing hscripts -E.G -grep 'hscripts' file1.txt 51.To print all lines without hscripts -E.G -grep v 'hscripts' file1.txt 52.To print the count of line that matches hscripts -E.G -grep -c 'hscripts' file1.txt

53.To print the lines that starts as hscripts -E.G -grep '^hscripts' file1.txt 54.To Search the files in HEC directory which has the string "include" - E.G -grep -c 'include' HEC/* 55.