Actions

Difference between revisions of "Linux"

From kemiko

Line 19: Line 19:
 
</pre>
 
</pre>
  
* find . -type f -exec grep -n "LITERAL/REGEX" {} /dev/null \; # search regular files for "LITERAL/REGEX" inside...printing "path/filename:line:content"
+
* find . -type f -exec grep -n "LITERAL/REGEX" {} /dev/null \;&nbsp;&nbsp;&nbsp;&nbsp;# search regular files for "LITERAL/REGEX" inside...printing "path/filename:line:content"
* find . -type f -exec ls -hlatr {} \; | sort -hk5,5 # long list all files under a directory, sort smallest to largest (human size)
+
* find . -type f -exec ls -hlatr {} \; | sort -hk5,5&nbsp;&nbsp;&nbsp;&nbsp;# long list all files under a directory, sort smallest to largest (human size)
* find . -maxdepth 1 -type f # list only regular files in current directory
+
* find . -maxdepth 1 -type f&nbsp;&nbsp;&nbsp;&nbsp;# list only regular files in current directory
* rm -rf PATH # remove a "PATH" and all content
+
* rm -rf PATH&nbsp;&nbsp;&nbsp;&nbsp;# remove a "PATH" and all content
* awk -F'SEPARATOR' '{print $NUMBER}' # print the column "NUMBER" delimited by "SEPARATOR"
+
* awk -F'SEPARATOR' '{print $NUMBER}'&nbsp;&nbsp;&nbsp;&nbsp;# print the column "NUMBER" delimited by "SEPARATOR"
* locate LITERAL # print the PATH of file name matching "LITERAL"
+
* locate LITERAL&nbsp;&nbsp;&nbsp;&nbsp;# print the PATH of file name matching "LITERAL"
* less -S FILE # page "FILE" with no line wrap
+
* less -S FILE&nbsp;&nbsp;&nbsp;&nbsp;# page "FILE" with no line wrap
* du -hd1 | sort -h # disk usage (human size),one level deep and sum by directory...pipe to sort smallest to largest
+
* du -hd1 | sort -h&nbsp;&nbsp;&nbsp;&nbsp;# disk usage (human size),one level deep and sum by directory...pipe to sort smallest to largest
* wget PATH # get "PATH" from http/ftp
+
* wget PATH&nbsp;&nbsp;&nbsp;&nbsp;# get "PATH" from http/ftp
* scp PATH1 username@hostname:PATH2 # put "PATH1" to "PATH2"
+
* scp PATH1 username@hostname:PATH2&nbsp;&nbsp;&nbsp;&nbsp;# put "PATH1" to "PATH2"
* scp -r PATH1 username@hostname:PATH2 # same as above, but recursively gets directory and all files under it
+
* scp -r PATH1 username@hostname:PATH2&nbsp;&nbsp;&nbsp;&nbsp;# same as above, but recursively gets directory and all files under it
* scp username@hostname:PATH1 PATH2 # get "PATH1" to "PATH2"
+
* scp username@hostname:PATH1 PATH2&nbsp;&nbsp;&nbsp;&nbsp;# get "PATH1" to "PATH2"
* scp username@hostname:PATH1 PATH2 # same as above, but recursively gets directory and all files under it
+
* scp username@hostname:PATH1 PATH2&nbsp;&nbsp;&nbsp;&nbsp;# same as above, but recursively gets directory and all files under it
* cat FILE # display contents of "FILE"
+
* cat FILE&nbsp;&nbsp;&nbsp;&nbsp;# display contents of "FILE"
* vi FILE # edit/view "FILE"
+
* vi FILE&nbsp;&nbsp;&nbsp;&nbsp;# edit/view "FILE"
* echo $VARIABLE # display contents of variable "VARIABLE"
+
* echo $VARIABLE&nbsp;&nbsp;&nbsp;&nbsp;# display contents of variable "VARIABLE"
* >FILE # zeros out "FILE"
+
* >FILE&nbsp;&nbsp;&nbsp;&nbsp;# zeros out "FILE"
* cp /dev/null FILE # zeros out "FILE"
+
* cp /dev/null FILE&nbsp;&nbsp;&nbsp;&nbsp;# zeros out "FILE"
* \COMMAND # unalias "COMMAND"
+
* \COMMAND&nbsp;&nbsp;&nbsp;&nbsp;# unalias "COMMAND"
* "COMMAND" # unalias "COMMAND"
+
* "COMMAND"&nbsp;&nbsp;&nbsp;&nbsp;# unalias "COMMAND"
* while [ 1 ]; do COMMANDS; sleep NUMBER; done # repeat COMMAND with NUMBER seconds between
+
* while [ 1 ]; do COMMANDS; sleep NUMBER; done&nbsp;&nbsp;&nbsp;&nbsp;# repeat COMMAND with NUMBER seconds between
* cat FILE | while read LINE; do COMMAND; done # read a file line by line doing a COMMAND until file's end
+
* cat FILE | while read LINE; do COMMAND; done&nbsp;&nbsp;&nbsp;&nbsp;# read a file line by line doing a COMMAND until file's end
  
* uname -a # lists basic system information
+
* uname -a&nbsp;&nbsp;&nbsp;&nbsp;# lists basic system information
* uptime # print time since system boot
+
* uptime&nbsp;&nbsp;&nbsp;&nbsp;# print time since system boot
* apt-get update # updates the system's package lists
+
* apt-get update&nbsp;&nbsp;&nbsp;&nbsp;# updates the system's package lists
* top # traditional performance monitor
+
* top&nbsp;&nbsp;&nbsp;&nbsp;# traditional performance monitor
* htop # improved performance monitor
+
* htop&nbsp;&nbsp;&nbsp;&nbsp;# improved performance monitor
* a2ensite kohlmeyer.us.conf # Apache...enable a virtual host
+
* a2ensite kohlmeyer.us.conf&nbsp;&nbsp;&nbsp;&nbsp;# Apache...enable a virtual host
* ffmpeg -ss 4.5 -i input.mp3 -t 1.7 output.mp3 # cut a mp3 from 4.5 seconds to 6.2 seconds
+
* ffmpeg -ss 4.5 -i input.mp3 -t 1.7 output.mp3&nbsp;&nbsp;&nbsp;&nbsp;# cut a mp3 from 4.5 seconds to 6.2 seconds

Revision as of 23:41, 17 November 2016

Favorite Commands:

Some Notation:
FILE: a filename
DIRECTORY: a directory
PATH: a directory/file location
LINE: a line's contents
COMMAND: a command like awk, cat, echo, grep, etc. 
LITERAL: a literal/static variable no REGEX
REGEX: "REGular EXpression"...a pattern matching expression
DATE: a date...format may vary
TIME: a time...format may vary
NUMBER: a numeric value
SEPARATOR: a field separator
VARIABLE: a variable
/dev/null: a device file representing nothing
read: read's stdin
  • find . -type f -exec grep -n "LITERAL/REGEX" {} /dev/null \;    # search regular files for "LITERAL/REGEX" inside...printing "path/filename:line:content"
  • find . -type f -exec ls -hlatr {} \; | sort -hk5,5    # long list all files under a directory, sort smallest to largest (human size)
  • find . -maxdepth 1 -type f    # list only regular files in current directory
  • rm -rf PATH    # remove a "PATH" and all content
  • awk -F'SEPARATOR' '{print $NUMBER}'    # print the column "NUMBER" delimited by "SEPARATOR"
  • locate LITERAL    # print the PATH of file name matching "LITERAL"
  • less -S FILE    # page "FILE" with no line wrap
  • du -hd1 | sort -h    # disk usage (human size),one level deep and sum by directory...pipe to sort smallest to largest
  • wget PATH    # get "PATH" from http/ftp
  • scp PATH1 username@hostname:PATH2    # put "PATH1" to "PATH2"
  • scp -r PATH1 username@hostname:PATH2    # same as above, but recursively gets directory and all files under it
  • scp username@hostname:PATH1 PATH2    # get "PATH1" to "PATH2"
  • scp username@hostname:PATH1 PATH2    # same as above, but recursively gets directory and all files under it
  • cat FILE    # display contents of "FILE"
  • vi FILE    # edit/view "FILE"
  • echo $VARIABLE    # display contents of variable "VARIABLE"
  • >FILE    # zeros out "FILE"
  • cp /dev/null FILE    # zeros out "FILE"
  • \COMMAND    # unalias "COMMAND"
  • "COMMAND"    # unalias "COMMAND"
  • while [ 1 ]; do COMMANDS; sleep NUMBER; done    # repeat COMMAND with NUMBER seconds between
  • cat FILE | while read LINE; do COMMAND; done    # read a file line by line doing a COMMAND until file's end
  • uname -a    # lists basic system information
  • uptime    # print time since system boot
  • apt-get update    # updates the system's package lists
  • top    # traditional performance monitor
  • htop    # improved performance monitor
  • a2ensite kohlmeyer.us.conf    # Apache...enable a virtual host
  • ffmpeg -ss 4.5 -i input.mp3 -t 1.7 output.mp3    # cut a mp3 from 4.5 seconds to 6.2 seconds