UNIX commands

Manipulating files and directories

  • cd - change directory -- Syntax: cd [<directory>]
  • ls - list directory contents -- Syntax: ls [flags] [<director(y/ies)/files(s)>]

 

Common Flags

  • -a - list all files including ., .. and all those beginning with a '.'
  • -s - show size of files
  • -l - show owner, permissions, size, group, etc.. of file
  • -C - show in columns
  • -F - append * to executables, / to directories, @ for links, etc.
  • -t - sort in reverse order by time
  • mkdir - Make a directory -- Syntax: mkdir <director(ies)>
  • rmdir - Removes a directory -- Syntax: rmdir <director(ies)>
  • rm - Remove files  -- Syntax: rm [<flags>] <file(s)>
  • -r - remove listed files and directories, all files in those directories, all sub-dirs and those files in listed directories, etc..
  • -f - don't ask if you want to remove a file
  • -i - ask before removing a file
  • cp - Copy files -- Syntax: cp [-r] <original(s)> <new file or directory>
  • -r – copy directories as well as files
  • mv - Move files -- Syntax: mv <original(s)> <directory/file>
  • mv <original> <new name>
  • ln - Make a link to a file -- Syntax: ln -s <original> <link>
  • file - Display what type of file a file is -- Syntax: file <file(s)>

 

Displaying files

  • cat - basic file display command -- Syntax: cat <file(s)>
  • page - Display file one page at a time -- Syntax: page <file(s)>
  • less - Display a file one page at a time with backwards and forwards movement -- Syntax: less <file(s)>

 

Editing files

  • vi - File editor -- Syntax: vi <file>
  • emacs - Powerful file editor and more -- Syntax: emacs [<options>] [<file>]
    • Tutorial: type 'control-h t'
  • pico - Simple text editor -- Syntax: pico <file>

 

The Internet

  • archie - Search FTP archive for files -- Syntax: archie [<flags>] <expression>
  • Common Flags:
  • -s : substring search
  • -e : exact search (default)
  • -l : show one find per line
  • -c : case-sensitive substring search
  • -t : sort results by date
  • -o :<file> : output to file <file>
  • ftp - Basic ftp interface -- Syntax: ftp [<host>]
  • gopher - Menu based information retrieval system -- Syntax: gopher [<host>]
  • lynx - World Wide Web hyper-text client -- Syntax: lynx
  • talk - User to user chat -- Syntax: talk <user> [@<host>] [<tty>]
  • telnet, rlogin - Connect to a remote computer -- Syntax: telnet <host> rlogin [-l <user-name] <host>
  • tin, rn, etc.. Usenet news readers -- Syntax: varies
  • finger - Find out information about a user or a machine -- Syntax: finger -l <user> [@<host>] finger @<host>

 

System info

  • ps - Find out what processes are running on the current machine -- Syntax: ps [<flags>]
  • Common flags:
  • -a : show all user (vs. system) processes
  • -x : show all user and system processes
  • -u : show which user is running a process and other extra information
  • w - Show who is on the system -- Syntax: w \
  • who - Show who is on the system -- Syntax: who
  • last - Shows a log of connections -- Syntax: last [<name>] [<tty>] [-<number>]
  • lpq - Shows files to be printed -- Syntax: lpq
  • whoami - Shows your login name -- Syntax: whoami

 

Getting help

  • man - access manual pages -- Syntax: man [<section>] <command> man -k <keyword>