Actions

Difference between revisions of "Linux"

From kemiko

 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<strong>Favorite Commands:</strong>
+
[[Linux Commands]]
 +
 
 +
 
 +
 
 +
<strong>Favorite Commands (Debian/Ubuntu):</strong>
 +
 
  
<pre>
 
 
Some Notation:
 
Some Notation:
FILE: a filename
+
<br>
DIRECTORY: a directory
+
" #": everything following this to the end of the line is a comment...you can also paste it...the shell will ignore it
PATH: a directory/file location
+
<br>
LINE: a line's contents
+
FILE: filename
COMMAND: a command like awk, cat, echo, grep, etc.  
+
<br>
LITERAL: a literal/static variable no REGEX
+
DIR: directory
 +
<br>
 +
PATH: directory/[file] location
 +
<br>
 +
LINE: line's contents
 +
<br>
 +
CMD: command like awk, cat, echo, grep, etc.  
 +
<br>
 +
LIT: literal/static variable no REGEX
 +
<br>
 
REGEX: "REGular EXpression"...a pattern matching expression
 
REGEX: "REGular EXpression"...a pattern matching expression
DATE: a date...format may vary
+
<br>
TIME: a time...format may vary
+
DATE: date...format may vary
NUMBER: a numeric value
+
<br>
SEPARATOR: a field separator
+
TIME: time...format may vary
VARIABLE: a variable
+
<br>
 +
NUM: numeric value
 +
<br>
 +
SEP: field separator
 +
<br>
 +
VAR: variable
 +
<br>
 +
URL: Uniform Resource Locator
 +
<br>
 
/dev/null: a device file representing nothing
 
/dev/null: a device file representing nothing
read: read's stdin
+
<br>
</pre>
+
read: shell builtin that read's stdin
 +
<br>
 +
&#42;: wildcard
 +
<br>
  
* 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&nbsp;&nbsp;&nbsp;&nbsp;# long list all files under a directory, sort smallest to largest (human size)
 
* find . -maxdepth 1 -type f&nbsp;&nbsp;&nbsp;&nbsp;# list only regular files in current directory
 
* rm -rf PATH&nbsp;&nbsp;&nbsp;&nbsp;# remove a "PATH" and all content
 
* awk -F'SEPARATOR' '{print $NUMBER}'&nbsp;&nbsp;&nbsp;&nbsp;# print the column "NUMBER" delimited by "SEPARATOR"
 
* locate LITERAL&nbsp;&nbsp;&nbsp;&nbsp;# print the PATH of file name matching "LITERAL"
 
* less -S FILE&nbsp;&nbsp;&nbsp;&nbsp;# page "FILE" with no line wrap
 
* 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&nbsp;&nbsp;&nbsp;&nbsp;# get "PATH" from http/ftp
 
* scp PATH1 username@hostname:PATH2&nbsp;&nbsp;&nbsp;&nbsp;# put "PATH1" to "PATH2"
 
* 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&nbsp;&nbsp;&nbsp;&nbsp;# get "PATH1" to "PATH2"
 
* scp username@hostname:PATH1 PATH2&nbsp;&nbsp;&nbsp;&nbsp;# same as above, but recursively gets directory and all files under it
 
* cat FILE&nbsp;&nbsp;&nbsp;&nbsp;# display contents of "FILE"
 
* vi FILE&nbsp;&nbsp;&nbsp;&nbsp;# edit/view "FILE"
 
* echo $VARIABLE&nbsp;&nbsp;&nbsp;&nbsp;# display contents of variable "VARIABLE"
 
* >FILE&nbsp;&nbsp;&nbsp;&nbsp;# zeros out "FILE"
 
* cp /dev/null FILE&nbsp;&nbsp;&nbsp;&nbsp;# zeros out "FILE"
 
* \COMMAND&nbsp;&nbsp;&nbsp;&nbsp;# unalias "COMMAND"
 
* "COMMAND"&nbsp;&nbsp;&nbsp;&nbsp;# unalias "COMMAND"
 
* 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&nbsp;&nbsp;&nbsp;&nbsp;# read a file line by line doing a COMMAND until file's end
 
  
* uname -a&nbsp;&nbsp;&nbsp;&nbsp;# lists basic system information
+
<ul>
* uptime&nbsp;&nbsp;&nbsp;&nbsp;# print time since system boot
+
<li>
* apt-get update&nbsp;&nbsp;&nbsp;&nbsp;# updates the system's package lists
+
  type CMD&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># cool builtin that tells you what you are looking at...</font>
* top&nbsp;&nbsp;&nbsp;&nbsp;# traditional performance monitor
+
  </li>
* htop&nbsp;&nbsp;&nbsp;&nbsp;# improved performance monitor
+
  <ul>
* a2ensite kohlmeyer.us.conf&nbsp;&nbsp;&nbsp;&nbsp;# Apache...enable a virtual host
+
  <li>
* 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
+
    alias
* vlc FILE&nbsp;&nbsp;&nbsp;&nbsp;# play audio or video FILE
+
  </li>
* eog FILE&nbsp;&nbsp;&nbsp;&nbsp;# display image FILE
+
  <li>
* gnome-system-monitor&nbsp;&nbsp;&nbsp;&nbsp;# graphical display of system resources
+
    builtin
* gimp&nbsp;&nbsp;&nbsp;&nbsp;# run GNU Image Manipulation Program
+
  </li>
 +
  <li>
 +
    command
 +
  </li>
 +
  <li>
 +
    etc.
 +
  </li>
 +
  </ul>
 +
</li>
 +
<li>
 +
  uname -a&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># lists basic system information</font>
 +
</li>
 +
<li>
 +
  uptime&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># print time since system boot</font>
 +
</li>
 +
<li>
 +
  top&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># traditional performance monitor</font>
 +
</li>
 +
<li>
 +
  htop&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># improved performance monitor</font>
 +
</li>
 +
<li>
 +
  mytop&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># a top like tool for MySQL</font>
 +
</li>
 +
<li>
 +
  itop&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># a top like tool I programmed for Informix 9.40.FC7</font>
 +
</li>
 +
<li>
 +
  du -hd1 | sort -h&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># disk usage (human size), one level deep and sum by directory...pipe to sort smallest to largest</font>
 +
</li>
 +
<li>
 +
  find . -type f -exec grep -in "LIT/REGEX" {} /dev/null \;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># case insensitive search regular files for "LIT/REGEX" inside file...printing "path/filename:line:content"</font>
 +
</li>
 +
<li>
 +
  find . -type f -exec ls -hlatr {} \; | sort -hk5,5&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># long list all files under a directory, sort smallest to largest (human size)</font>
 +
</li>
 +
<li>
 +
  find . -maxdepth 1 -type f&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># list only regular files in current directory</font>
 +
</li>
 +
<li>
 +
  rm -rf PATH&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># remove a "PATH" and all content</font>
 +
</li>
 +
<li>
 +
  awk -F'SEP' '{print $NUM}'&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># print the column "NUM" delimited by "SEP"</font>
 +
</li>
 +
<li>
 +
  locate LIT&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># print the PATH of file name matching "*LIT*"</font>
 +
</li>
 +
<li>
 +
  less -S FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># page "FILE" with no line wrap</font>
 +
</li>
 +
<li>
 +
  wget URL&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># get "URL" from http/ftp</font>
 +
</li>
 +
<li>
 +
  scp PATH1 username@hostname:PATH2&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># put "PATH1" to "PATH2"</font>
 +
</li>
 +
<li>
 +
  scp -r PATH1 username@hostname:PATH2&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># same as above, but recursively puts directory and all files under it</font>
 +
</li>
 +
<li>
 +
  scp username@hostname:PATH1 PATH2&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># get "PATH1" to "PATH2"</font>
 +
</li>
 +
<li>
 +
  scp -r username@hostname:PATH1 PATH2&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># same as above, but recursively gets directory and all files under it</font>
 +
</li>
 +
<li>
 +
  cat FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># display contents of "FILE"</font>
 +
</li>
 +
<li>
 +
  vi FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># edit/view "FILE"</font>
 +
</li>
 +
<li>
 +
  echo $VAR&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># display contents of variable "VAR"</font>
 +
</li>
 +
<li>
 +
  >FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># zeros out "FILE" keeping current attributes</font>
 +
</li>
 +
<li>
 +
  cp /dev/null FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># zeros out "FILE" keeping current attributes</font>
 +
</li>
 +
<li>
 +
  touch FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># creates a FILE of zero size if does not exist or updates file's timestamp to current time</font>
 +
</li>
 +
<li>
 +
  \CMD&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># unalias "CMD"</font>
 +
</li>
 +
<li>
 +
  "CMD"&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># unalias "CMD"</font>
 +
</li>
 +
<li>
 +
  while [ 1 ]; do CMD; sleep NUM; done&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># repeat CMD with NUM seconds between/wait</font>
 +
</li>
 +
<li>
 +
  cat FILE | while read LINE; do CMD; done&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># read a file line by line doing a CMD until file's end</font>
 +
</li>
 +
<li>
 +
  apt-get update&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># updates the system's package lists</font>
 +
</li>
 +
<li>
 +
  a2ensite kohlmeyer.us.conf&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># Apache...enable a virtual host</font>
 +
</li>
 +
<li>
 +
  ffmpeg -ss 4.5 -i input.mp3 -t 1.7 output.mp3&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># cut a mp3 from 4.5 seconds to 6.2 seconds</font>
 +
</li>
 +
<li>
 +
  vlc FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># play audio or video FILE</font>
 +
</li>
 +
<li>
 +
  eog FILE&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># display image FILE</font>
 +
</li>
 +
<li>
 +
  gnome-system-monitor&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># graphical display of system resources</font>
 +
</li>
 +
<li>
 +
  gimp&nbsp;&nbsp;&nbsp;&nbsp;<font color="#AAAAAA"># run GNU Image Manipulation Program</font>
 +
</li>

Latest revision as of 11:51, 11 June 2017

Linux Commands


Favorite Commands (Debian/Ubuntu):


Some Notation:
" #": everything following this to the end of the line is a comment...you can also paste it...the shell will ignore it
FILE: filename
DIR: directory
PATH: directory/[file] location
LINE: line's contents
CMD: command like awk, cat, echo, grep, etc.
LIT: literal/static variable no REGEX
REGEX: "REGular EXpression"...a pattern matching expression
DATE: date...format may vary
TIME: time...format may vary
NUM: numeric value
SEP: field separator
VAR: variable
URL: Uniform Resource Locator
/dev/null: a device file representing nothing
read: shell builtin that read's stdin
*: wildcard


  • type CMD    # cool builtin that tells you what you are looking at...
    • alias
    • builtin
    • command
    • etc.
  • uname -a    # lists basic system information
  • uptime    # print time since system boot
  • top    # traditional performance monitor
  • htop    # improved performance monitor
  • mytop    # a top like tool for MySQL
  • itop    # a top like tool I programmed for Informix 9.40.FC7
  • du -hd1 | sort -h    # disk usage (human size), one level deep and sum by directory...pipe to sort smallest to largest
  • find . -type f -exec grep -in "LIT/REGEX" {} /dev/null \;    # case insensitive search regular files for "LIT/REGEX" inside file...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'SEP' '{print $NUM}'    # print the column "NUM" delimited by "SEP"
  • locate LIT    # print the PATH of file name matching "*LIT*"
  • less -S FILE    # page "FILE" with no line wrap
  • wget URL    # get "URL" from http/ftp
  • scp PATH1 username@hostname:PATH2    # put "PATH1" to "PATH2"
  • scp -r PATH1 username@hostname:PATH2    # same as above, but recursively puts directory and all files under it
  • scp username@hostname:PATH1 PATH2    # get "PATH1" to "PATH2"
  • scp -r 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 $VAR    # display contents of variable "VAR"
  • >FILE    # zeros out "FILE" keeping current attributes
  • cp /dev/null FILE    # zeros out "FILE" keeping current attributes
  • touch FILE    # creates a FILE of zero size if does not exist or updates file's timestamp to current time
  • \CMD    # unalias "CMD"
  • "CMD"    # unalias "CMD"
  • while [ 1 ]; do CMD; sleep NUM; done    # repeat CMD with NUM seconds between/wait
  • cat FILE | while read LINE; do CMD; done    # read a file line by line doing a CMD until file's end
  • apt-get update    # updates the system's package lists
  • 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
  • vlc FILE    # play audio or video FILE
  • eog FILE    # display image FILE
  • gnome-system-monitor    # graphical display of system resources
  • gimp    # run GNU Image Manipulation Program