Guest User

Linux Commands

a guest
Nov 15th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | Software | 0 0
  1. [flags]
  2.  
  3. - Can combine commands flags as long as they don't take an argument
  4. - Separate them if they take arguments
  5.  
  6.  
  7.  
  8.  
  9. [networking]
  10.  
  11. # ss
  12. - shows open sockets and connections
  13.  
  14.  
  15. # ssh
  16.  
  17. ## -t
  18. - use when need interactive shell for htop
  19.  
  20. -t fish
  21. - use specified shell
  22.  
  23.  
  24.  
  25.  
  26.  
  27. [file management]
  28.  
  29. # borg
  30.  
  31. ### examples
  32.  
  33. borg list /mnt/windows//Users/Daniel/Documents/linux_backup
  34. - List borg snapshots in repo
  35.  
  36. borg info /mnt/windows//Users/Daniel/Documents/linux_backup::version-0.01
  37. - List files in a snapshot
  38.  
  39. # ln
  40.  
  41. ## -s
  42. - create symbolic links
  43.  
  44. ### examples
  45. ln -s <source path> <link name>
  46. - creates link to directory
  47.  
  48.  
  49.  
  50.  
  51.  
  52. [network file management]
  53. # scp
  54.  
  55. - File destination must have sshd running
  56. - scp (source) (destination)
  57. - source is always first
  58.  
  59. ### examples
  60.  
  61. scp user@ip:path destination
  62. - copy file from source to destination
  63.  
  64.  
  65. scp path ip:destination
  66. - copy file from source to destination
  67.  
  68. # git
  69.  
  70.  
  71. ### examples
  72.  
  73. git add . -> git commit -m "description" -> git push
  74. - Add all files in current directory to commit and then push
  75.  
  76. git clone url.git
  77. - copy repo
  78.  
  79.  
  80.  
  81.  
  82. [audio]
  83.  
  84. # ffmpeg
  85.  
  86. ### examples
  87.  
  88. ffmpeg -i {{path/to/video.mp4}} -vn {{path/to/sound.mp3}}
  89. - Extract the sound from a video and save it as MP3
  90.  
  91.  
  92. ffmpeg -i {{path/to/input_video.mp4}} -ss {{mm:ss}} -to {{mm2:ss2}} {{[-c|-codec]}} copy {{path/to/output_video.mp4}}
  93. - Trim a video from a given start time mm:ss to an end time mm2:ss2 (omit the -to flag to trim till the end)
  94.  
  95.  
  96. ffmpeg -i {{path/to/input_video}}.avi {{[-c|-codec]}}:a aac -b:a 128k {{[-c|-codec]}}:v libx264 -crf 23 {{path/to/output_video}}.mp4
  97. - Convert AVI video to MP4. AAC Audio @ 128kbit, h264 Video @ CRF 23
  98.  
  99.  
  100.  
  101.  
  102.  
  103. [packages]
  104.  
  105. # pacman
  106.  
  107. ### examples
  108.  
  109.  
  110. pacman -Qet
  111. - To list all packages explicitly installed and not dependencies
  112.  
  113.  
  114.  
  115.  
  116.  
  117. [text search]
  118. # rg
  119. - recursively search directory for every matching word
  120.  
  121. # grep
  122. - find word in file
  123.  
  124. ## -E
  125.  
  126. - extend expression, can check for multiple chars
  127.  
  128. ## -v
  129.  
  130. - only grep things that don't match
  131.  
  132.  
  133. ## -x
  134.  
  135. Select only those matches that exactly match the whole line.
  136. Can be used to find sections like Synopsis on man Pages
  137.  
  138. ## -A num
  139. - After grep finds line print the give argument number of lines
  140.  
  141.  
  142. ### examples
  143.  
  144. grep -E '\b[a-zA-Z]{5}\b' words_alpha.txt | grep -Ev '[clntsare]' | grep -E '[oi]' | grep -Ev '^..i' | grep -Ev '^.o' > out
  145. - wordle 1 liner, first sorts words by 5 char words then removes words than contain clntsare chars, then only includes words with oi chars, then only words which don't have i or o
  146. in those positions
  147.  
  148. grep -Ev '(^..i)|(^.o)'
  149. - combine with or into one statement
  150.  
  151. grep -E '[[:upper:]][[:lower:] ]*\.' linux/helix.md
  152. - find sentences
  153.  
  154. grep -E '[xlp]'
  155. - grep for xlp chars anywhere in word
  156.  
  157. [text processing]
  158.  
  159.  
  160. # awk
  161.  
  162. ### EXAMPLES
  163.  
  164. awk {print $3}
  165. - print third word in sentence
  166.  
  167. # cat
  168.  
  169. ## -n
  170.  
  171. show line numbers
  172.  
  173. ## -s
  174.  
  175. don't show empty lines
  176.  
  177.  
  178. # sort
  179. - sort text alphabetically, numerically etc.
  180. - by default sorts by a-z
  181.  
  182. ## -k{num}
  183. - sort by given text field instead of default
  184.  
  185. ## -n
  186. - numeric sorting
  187.  
  188. ## -r
  189. - revese order
  190.  
  191. ### examples
  192.  
  193. sort -n -k7
  194. - sort the 7th text field in a file numerically low to high
  195.  
  196.  
  197.  
  198. [file search]
  199.  
  200. # find
  201. - By default has no maxdepth
  202.  
  203. can use -or -and -not together
  204.  
  205. ## -mount
  206.  
  207. - dont search directories of mounted hard drives
  208.  
  209. ### examples
  210. find . -name "*.txt" -or -name "*.md" - find md or txt.
  211. - this is fish syntax, in bash this would use parentheses
  212.  
  213. find . -name "*.md" -not -name "*hist*"
  214. - find all .md files that do note contain the word hist
  215.  
  216. ## -iname
  217. - case insenitive search
  218.  
  219. ## cmin (+/-)num
  220. - find files creation time
  221. - + and - arguments say less than or greater than give number of minutes
  222.  
  223. ## ctime (+/-)num
  224. - same as cmin but uses days for num
  225.  
  226. ## mtime / mmin
  227. - like ctime/cmin but last modified time
  228.  
  229. ## -or
  230. - use multiple separate parameters
  231. - put after -name
  232.  
  233. ## -and
  234. - like or but both expressions must be true
  235.  
  236. ## -not
  237. - like and but both are false
  238.  
  239. ### examples
  240.  
  241. find Downloads/ -type f -name "*.md" -or -type f -name "*.rar"
  242. - find all .rar and .md files
  243.  
  244. find . -maxdepth 1 -type f ! -name "*.mp4" -exec mv "{}" "{}.mp4" \;
  245. - finds all files in current directory that don't have the .mp4 extension and appends .mp4 onto the
  246.  
  247.  
  248.  
  249.  
  250.  
  251. [disk]
  252.  
  253. # df
  254. - shows total disk usage
  255.  
  256. # which
  257. - shows given exe path
  258.  
  259. [users]
  260.  
  261. # su
  262. - switch to another user
  263.  
  264.  
  265.  
  266.  
  267.  
  268. [proceses]
  269.  
  270. # ps
  271.  
  272. ## --sort
  273. - Sorts from low to high of specifier
  274.  
  275. --sort specifier
  276.  
  277. Specifiers :
  278.  
  279. %cpu
  280. %mem
  281.  
  282. # jobs
  283. - list active jobs
  284.  
  285. # pstree
  286. - list process tree
  287.  
  288. # jobs
  289. - command &
  290.  
  291. ## fg %num
  292. - takes job number and puts it into the foreground (like without &)
  293.  
  294. ## bg %num
  295. - puts jobs back into background
  296.  
  297. # xargs
  298.  
  299. - when using xargs use --null to also include files with spaces in name
  300.  
  301.  
  302.  
Advertisement
Add Comment
Please, Sign In to add comment