BASH 41
OS Lab - All work till Mid Guest on 28th November 2021 10:36:22 PM
  1. ls - used to list files
  2. date - to show current date
  3. cal - calendar
  4.  
  5. -a and other type of syntax in commands are called wild cards.
  6. init 0 sutdown
  7. init 1 single user mode
  8. init 2 multiple user mode with no network
  9. init 3 multiple user mode under CLI
  10. init 4 User definable
  11. init 5 multiple user mode with GUI
  12. init 6 reboot the system
  13.  
  14. To check IP info:
  15. ip add
  16. ifconfig
  17.  
  18. ping - to see if other server is active
  19.  
  20. man - shows the manual of any command
  21. whoami - shows the user
  22. which - finds the path
  23. e.g, which ftp
  24. whereis - detailed patch
  25. pwd - shows the current directory.
  26.  
  27. ls displays three permissions.
  28. r = read
  29. w = write
  30. x = execute
  31. and d means directory.
  32. if ls shows - instead of d then its file.
  33.  
  34. ls / shows all file present
  35.  
  36. rwx/-wx/r-x
  37. the first part is user, second part is group, third part is others.
  38. - means no permission
  39.  
  40. ls in detail:
  41. ls -a shows hidden files
  42. ls -lS - sorts according to file size
  43. ls -d*/ to list all directories
  44. ls *.txt - to show specific extensions
  45.  
  46. whatis - shows information of any command in single line
  47. tracert - does routing
  48.  
  49. cd - to change the directory.
  50.  
  51. ls *.* - list files only with extensions
  52. mkdir - create directory
  53.  
  54. mkdir -p - to create folder within a folder
  55. e.g, mkdir -p a/b/c
  56. mkdir names/{austin,John} - creates two folders, austin and John.
  57.  
  58. history - shows all the commands used on server by user line by line
  59. ! - runs the old command by writing the number found from history command
  60. e.g, !2
  61.  
  62. cat - used to display text file, copy, append
  63.  
  64. cat > file.txt
  65. > used to create a file and in insert mode.
  66.  
  67. CTRL + C to save.
  68. To append just use >>
  69. cat > abc.txt > stdin > standard input
  70. cat abc.txt > stdout > standard output
  71.  
  72. cat file.txt abc.txt > out.txt - combines two file into new one
  73.  
  74. head - view top 10 line
  75. head -n 5 file.txt - shows first five top lines
  76.  
  77. tail - to view last 10 lines
  78.  
  79. cat -b - show lines that are not empty
  80. cat -E shows $ at end, means end of line.
  81.  
  82. less file.txt - to open a file, search, etc.
  83. Write / to search for file
  84.  
  85. less +/test file.txt - Directly search test in file .txt
  86. Press g in less to go up
  87. press G in less to go to end the of file.
  88.  
  89. cp source path destination path
  90. to copy
  91. mv - to rename file
  92.  
  93. mv oldfile.txt newfile.txt
  94. mv - also used to move files.
  95.  
  96. grep - used for pattern matching
  97. grep "great" file.txt
  98. grep -i - ignore case sensitive
  99. grep -o - only print the matched parts of a matching line
  100. grep -n - print with line number
  101. wc - word count
  102. wc -l - show word count
  103.  
  104. grep -i -o "is" file.txt | wc -l - shows the amount of is word in the file
  105. grep "great" file.txt | wc -l - shows the amount of great word in the file
  106. -l - number of line
  107.  
  108. ps -u username - shows all the process of the user
  109.  
  110. rm -i filename.txt - remove file and -i means interactive
  111. rm -r - to remove files/folders recursively, means deleting everything such as files in different sub folder.
  112. -f - to skip asking.
  113. find - check if file exists
  114. e.g, find /root/sandbox/test -name *.txt - to find all files with .txt extension
  115.  
  116. CPU Info: lscpu
  117. OS Version: cat /etc/os-release
  118.  
  119. df - shows the disk that is free
  120. df -h - to show disk free in human readable form
  121. du - to show the disk used
  122. du -sh - to show file size only
  123.  
  124. free - to show the RAM
  125.  
  126. rmdir - only remove directory that are empty
  127. rmdir -pv - remove directory even if its not empty
  128. v - verbose
  129. p - parent
  130. However, it will not remove the folder if the file is present.
  131.  
  132. nano - a text editor
  133.  
  134. chmod is used to set the file permission
  135. + to add permission
  136. - to remove permission
  137.  
  138. chmod o-x file.txt
  139. take execute permission from others
  140.  
  141. u - user
  142. g - group
  143. o - others
  144. r - read
  145. w - write
  146. x - execute
  147.  
  148. chmod ugo = rw
  149. all three gets read and write permission
  150. chmod ugo-rw file.txt remove all permissions from all

Coding Base is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.