Actions

Linux

From kemiko

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