featured computer 850

Linux Commands Summary Reference List

Open Document format Open source office doc. Much better for printing.

cal = Calendar.Prints a calendar for [[month] year].cat = Catenate.Joins files end to end or send file to standard output.

  • -n = Numbers all lines as they are written to std. output.
  • -E = Ends of lines are marked with dollar signs.
  • -s = Squeeze so that there is never more than one blank line in a row.
  • -v = Show non-printing characters (control as ^M and alt as M-).
  • -t = Tabs are marked with ^I.

cd = Change Directory.”..” is one directory up. Without a path, sends you home.chgrp = Change Group.Changes the group associated with file-list. Group is the name or group ID of new group.
Syntax: chgrp [options] group file_list

  • -c = Changes. List only those files whose group ownership changes.
  • -R = Recursive. When directory is listed, changes all files within it.
  • -v = Verbose. List all files and whether changed ownership or not.

chmod = Change Mode.Changes how a file can be accessed.
Syntax: chmod [options] who operation permission file-list

  • who: u=user, g=group, o=other, a=all (can use in place of ugo).
  • operation: “+”=adds permission, “-“=removes permission, “=”=sets permissions specified user, resets permissions for that user class.
  • permission: r=read, w=write, x=execute, t=sets sticky bit, s=sets user or group ID when executed.
  • -c = Changes. Display list of files that have their permissions changed.
  • -R = Recursive. Descends directory and sets all files to those specified.
  • -v = Verbose. Describes whole operation.

Using the number method:
Read=4, Write=2, Execute=1
Order is user, group, other.
Ex: chmod 755 /home/mydir/myfilechown = Change Owner.Options available are -c, -R, and -v and above.
Syntax: chgown [options] owner file_listcmp = Compare.Unlike diff, also compares binary files. Exit status=0 if same; status=1 if different. If file2 is omitted, uses standard input.
Syntax: cmp [options] file1 [file2]

  • -i n = Skips first n bytes in each file.
  • -c Characters. Shows bytes where files first differ.
  • -s Silent. Suppress output.
  • -l Long/verbose. Show all bytes that differ.

comm = Compare two SORTED files.Outputs 3 columns: Lines only in file1, lines found only in file2 and lines common to both. Use a hyphen for file1 or file2 to read standard input.
Syntax: comm [opt] file1 file2

  • -1 = Do not display column1.
  • -2 = Do not display column2.
  • -3 = Do not display column3.

cp = Copy.Shorthand for working directory is “.”
Syntax: cp source-file destination-file.

  • -b = Backup. If overwriting a file, makes a backup copy, same name with tilde (~) appended.
  • -i = Interactive. Prompts if overwriting a file.
  • -p = Preserve. Preserves the owner, group and permissions when copying.
  • -r = Recursive. Can use if destination is a directory. If any files in source list are a directory, will copy whole directory structure.

date = Date.Displays the time and date. Superuser can specify newdate as nnddhhmm[cc[yy]] where nn=month, dd=day, hh=24 hour, mm=minute, cc=1st 2 year digits, yy=last 2 year digits. Use help option for format.
Syntax: date [opt] [+format] OR date [opt] newdate

  • -u = Universal. Sets date in Greenwich Mean Time and is converted by date utility.
  • –help = How to use date and list of field descriptors.

df = Disk Free.Reports on free space in blocks left on any mounted device. Usually 1kb (1024 bytes) per block. Without an argument, reports on each mounted device.
Syntax: df [opt] [file_list]

  • -h = Human Readable sizes (KB, MB, GB)
  • -F “type” = One of file system types listed in /etc/vfstab
  • -t = Lists free AND allocated space (see “du”)
  • -i = Report on inodes instead of blocks

diff = Difference.Displays the difference between two files on a line-by-line basis. If a hyphen is used for either file, diff uses standard input. Output is line number that is different, file1 differences are marked with “<” and file2 differences are marked with “>”, a=add, d=delete, c=change. If file is too big, use bdiff.
Syntax: diff [options] file1 file2

  • -b = blanks. Ignore differences in blanks, tabs and spaces.
  • -q = quick?. No detail, only reports if files differ
  • -c [or -C lines]. Context. Lists lines surrounding the differences for context (default=3)
  • -i = ignore. Ignore differences in case when comparing files
  • -e = editor. Creates a script for “ed” editor to make file1 into file2 (may not work)

du = Disk Usage.With no options does current directory.
Syntax: du [options] [file-list]

  • -h = Human-Readable units used instead of bytes
  • -a = all. Space used by all files, not just directories
  • –s = summary. Only the totals for each directory
  • -s = silent. Display only totals

echo = EchoEchos argument, followed by new line, to standard output.
The shell recognizes wildcards in the message.
Syntax: echo [options] message

  • -n = Suppresses the newline terminating the message
  • –help = Get help using echo
    • Escape Characters:
    • \a = bell
    • \c = suppress newline at end
    • \n = newline
    • \t = horizontal tab
    • \v = vertical tab
    • \\ = backslash

file = FileClassifies files according to their contents. Works by examining the beginning of a file…the results are not always correct! Uses /etc/magic to help determine file types.
Syntax: file [option] file_list

  • -f = File option will read list of files from a file instead of command line
  • -i = Ignores symbolic links

find = FindPerforms searches for files with many options (many not listed here). Searches current directory or all subdirectories in “path”. A space separating criteria is logical AND; separate criteria with “-o” for a logical OR. Negate any criteria by preceding with a “!”.
Syntax: find [path(s)] [expression]

  • -atime +/-n = Files accessed more or less than n days from now
  • -group group = Files belonging to a group or group ID
  • -inum n = File with a specific inode number n
  • -mtime +/-n = Files modified more or less than n days from now
  • -name filename = Searches to match the name of a file. Ambiguous references must be quoted
  • -newer filename = Files modified more recently than filename
  • -nogroup = Files belonging to a group not in /etc/group
  • -nouser = Files owned by users not in /etc/passwd file
  • -perm nnn = Files with permission mode=nnn
  • -size +/-nk = Files with size greater than or less than n kilobytes
  • -type filetype = Searches to match the following types
    • b = Block special file
    • c = Character special file
    • d = Directory file
    • f = Ordinary file
    • p = Fifo (named pipe)
    • l = Symbolic link
  • -user user = Files owned by a username or user ID

fmt = FormatAttempts to make all non-blank lines of a file nearly equal by moving the “newline” characters. Indentations and spaces between words aren’t changed. Moves formatted version of files in file_list to standard output. Single option -n changes output to n characters. The default is 72.
Syntax: fmt [option] [file_list]ftp = File Transfer Protocol.Interactive client program for moving files between computers. Remote computer must be running the ftp service. You need an account or you can try “anonymous”.

  • -i = interactive on/off. I need to use on my Web server not to get prompted with mput or mget (e.g., ftp -i machine_name)
  • -v = verbose.
  • FTP Commands
  • ascii = Sets transfer for plain-text files (usually the default)
  • bin[ary] = Sets transfer for binary files (pictures, MS Word, etc.)
  • bye = Closes connection to remote computer and ends ftp session
  • cd directory = Change Directory or takes you to remote home
  • delete filename = Deletes remote file
  • disc[connect] = Closes connection and ends ftp session
  • get file1 [file2] = Get file to the directory you started ftp. Can rename as file2
  • lcd = Local Change Directory (on starting machine)
  • ls = List command, as described below
  • mdelete = Deletes multiple files listed or described with wildcards
  • mget = Gets multiple files listed or described with wildcards
  • mkdir = Make Directory file on remote machine
  • mput = Puts multiple files listed or described with wildcards
  • open machine_name = Open a connection to a remote host
  • put file1 [file2] = Put file from local machine to remote machine (option to rename)
  • pwd = Print Working Directory (on remote machine)

Note on mget and mput: I’ve seen a bunch of searches for mget & mput “recursive” or “directory” and I haven’t seen a command to do this. Try first using the “tar” command below to bundle the directories and then transfer the resulting file.grep = Global Regular Expression ParserSearches one of more files for a string or regular expression. Without options, sends matches to standard output. Using “*” for file list, searches all files in directory. Exit codes sent are 0=match, 1=no match, 2=error/not accessible.
Syntax: grep [options] pattern [file_list]

  • -c = count. Displays only the number of lines that have a match
  • -h = no header. For multiple files, leave out preceding file name
  • -i = ignore case.
  • -l = list. Display only the file names that have a match
  • -n = number. Precede each matching line with its line number
  • -q = quiet. Only send exit code
  • -s = suppress. Do not send error messages
  • -v = reverse. Will display all lines NOT matching the pattern
  • -w = word. Matches to a specific word and leaves out any other forms or longer words

gzip and gunzip = Zip and UnzipCompresses and uncompresses one or more files. When using gzip, original file is deleted and new file has the extension “.gz”. With recursive option, gzip will recursively compress subdirectories. Can also read from standard input. File attributes of owner and permission aren’t changed. [tar -z = gzip]. Text files reduced 60%+.
Syntax: gzip [options] [file_list]

  • -d = decompress. The same as using gunzip.
  • -# = compression level. Substitute “#” with a number from 1 (fastest) to 9 (best). Default=6.
  • -f = force compression and don’t give me any back-talk
  • -r = recursively descend directory tree to (de)compress
  • -c = sends results to standard output instead of overwriting file
  • -v = verbosely describe what was done

headDisplays the beginning of a file or standard input.
Syntax: head [options] [file_list]

  • -n = number of lines to display (I think 10 is the default?)
  • -q = quiet. Don’t show header info. for multiple files

info = InformationInformation utility developed by GNU project. Hypertext system on Linux shells, utilities and programs. Uses “node” to mean a screenful of stuff. n = next, p = previous, d = initial node. “C-h” for help is “Control-h”.killTerminates processes you own or are lord over. Sends software termination signal “15” by default. Use kill -9 if you REALLY want to kill process. You can use “ps” utility to get Process ID numbers. Superuser “kill -9 0” shuts down system.
Syntax: kill [options] PID_listlessText file pager like “more” utility but more powerful (less is more). Displays a command prompt after each screen of text.
Syntax: less [options] [file_list]

  • -i = ignore case. Searches for lower-case strings match both lower and upper case.
  • -m = reports the percentage of file viewed with each prompt
  • -N = line numbers are displayed
  • -s = suppresses multiple blank lines to a single line (while viewing)
  • -xn = sets tab stops “n” spaces apart (default=8)
  • -zn = sets scroll size to “n” lines (default is screen size)
  • less commands
  • [n]spacebar = scroll 1 page at a time
  • h = help is displayed (using less)
  • [n]return = jumps down by n lines at a time
  • [n]b = go back n lines
  • q = quit

ln = LinkCreate a link (pointer) to a single file/inode number. You can also create a directory link to a file list using second syntax. A Windows shortcut is like “ln -s”.
Syntax1: ln [options] file1 new_link
Syntax2: ln [options] file_list new_directory_link

  • -s = symbolic. An indirect link containing the pathname to a file. Can be a directory.
  • -i = interactive. Prompts you if “new_link” already exists
  • -f = force. Forces “new_link” to be overwritten if it exists
  • -b = backup. Works only with -f, makes a backup by adding “~” to file name

ls = ListShows files and directories in current directory if one not named. The columns using the “long” option (-l) are: The type of file (e.g., d=directory, l=link, -=normal file); 3 sets of 3 permissions for the owner, group and others; the # of hard links to the file; name of the owner; name of the group file belongs to; size in bytes (use -h to get human readable sizes) for most files, but if a device then it shows major and minor device numbers; time last modified (-t sorts by time last modified); filename.

  • -a = all files (includes hidden files and directories)
  • -b = displays nonprinting escape sequences
  • -c = with -l, displays last time inode # was changes
  • -C = vertical columns; the default for terminal
  • -F = format: shows slash after directory,asterisk after files and @ after links
  • -l = long format (verbose)
  • -L = gives info on files referenced by links instead of links themselves
  • -o = no color
  • -r = reverse. lists filenames (or times) in reverse order
  • -R = recursively lists subdirectories.
  • -t = time. Sorts by time last modified
  • -u = with -l, displays last accessed time; with -t, sorts by time last accessed
  • -x = sorts files horizontally
  • -X = sorts files by their extensions
  • -1 = sorts in single column (default if not to terminal)

man = Manual (also xman)Online documentation, sometimes outdated. Follow man with topic name or “man man” to learn about it. Sections include (1) user programs, (2) system calls, (3) library functions and subroutines, (4) special files (devices), (5) file formats, (6) games, (7) miscellaneous, (8) system administration, (9) kernel internal variables and functions. Note: Unless you include a manual section, man gives the earliest occurrence in the manual of the word. Ex: man 2 write looks in “system calls” for write.mkdir = make directorySyntax: mkdir [options] directory_list

  • -m = mode. Set the permissions to mode given (see chmod).

mv = MoveEffects of “cut and paste” or “rename”. Using either relative or absolute path names
Syntax1: mv [options] old-file new-file
Syntax2: mv [options] old-file-list new-directory

  • -b = backup. Creates backup of files that would have been overwritten. Adds “~” to filename.
  • -f = force. Cause mv not to prompt. Need “write” permission in target directory.
  • -i = interactive. Prompts you if file will be overwritten.
  • -u = update. Causes mv to compare modification times of files if being overwritten and only replace with newer.

passwd = PasswordUse to change your password at any time.pastePastes corresponding lines of two files. Like cat but separated by a tab. Use “>” to put in a file.
Syntax: paste [options] file_list/std. input

  • -d = delimiter list. Can have a character between each item instead of a tab. If a list, the characters change with each spacing.

ps = Process statusDisplays info. on running processes, either all or ones you specify.
Syntax: ps [options] [process # list]

  • -a = all. Reports on all user processes
  • -f = family? Indents each child process and lists it after its parent
  • -h = header. Omits header information
  • -l = long. Shows more detailed info. about processes
  • -m = memory. Display memory size information in 1024-byte blocks
  • -u = username. Adds username, time started, %CPU, %MEM to display
  • -w = wide. Extends the display so it is wrapped vs. truncated
  • -x = extra? Includes processes not attached to terminals. Add to “a” to get true ALL
  • Process Status Display
  • COMMAND = Command line that started process (always last)
  • %CPU = Percent of CPU time process is using (approximate)
  • F = Flags associated with the status
  • %MEM = Percent of RAM that process is using
  • PID = Process Identification Number
  • PPID = Parent Process Identification Number
  • PRI = Priority
  • RSS = Resident Set Size (blocks of memory)
  • SIZE = Size (in blocks) of process core image
  • START = Time the process started
  • STAT = Status
    • D = Sleeping and cannot be interrupted
    • N = May have a reduced priority
    • R = Available for execution
    • S = Sleeping
    • T = Either stopped or being traced
    • Z = Zombie that is waiting for child to terminate
  • TIME = Elapsed time process has been running
  • TTY = Terminal name controlling process
  • UID = User ID of person who owns process
  • USER = Username of person who owns the process
  • WCHAN = If process is waiting, gives address of kernel function that caused wait

pwd = Print working directoryThe name says it all. Use with “whoami” if you space out…rm and rmdir = RemoveRemove a file/link or use rmdir to remove an empty directory.
Syntax: rm [options] file_list

  • -f = forced removal without back-talk
  • -i = interactive. Asks before removing each file
  • -r = recursive. Deletes contents of a directory, including all of its subdirectories. Be careful.

rpm = Redhat Package Manager.Useful for installing precompiled software, managing updates, viewing info. on packages, etc. Works with most UNIX systems.
Syntax: rpm options rpm_file

  • -ivh = INSTALLATION of new package
  • -Uvh = UPDATE existing package (this also works with no previous package)
  • -Fvh = “Refresh” a package
  • -a = Query all packages
  • -c = List configuration files changed by package
  • -e = UNINSTALL existing package
  • -l = List all the FILES within a package
  • -q = Query package for its bio (raison d’Γͺtre)
  • -qlp = Shows what files a package installs
  • -qip = Find out what a package does

su = Superuser/substitute userType “exit” to assume role of previous user.tailDisplays the end of a file, the last 10 lines by default. Will display file names between files in file_list.
Syntax: tail [options] [file_list]

  • -f = follow. After copying last line, tail waits and copies additional lines from the file as it grows. Use kill to stop
  • -n = Show the last “n” lines of the file
  • +n = Show the end of the file, starting with line “n”
  • -q = quiet. Suppress header information between files

tar = Tape archiveCan create, add to, list and retrieve files from an archive file.
Syntax: tar option [modifiers] [file_list]

  • Options
  • -c = create. Stores the named file(s) in a new archive. If directory, works recursively
  • -r = append. Writes the file list to the end of an archive
  • -t = table of Contents. Without file_list, produces a table of contents of archive. Works with verbose option
  • -u = update. Adds the files to the archive if they are not already in the archive
  • -x = extract. Extracts the file list (or all files) from the archive.
  • –help = complete list of options.
  • Modifiers – If takes an argument, must be last.
  • -C directory= Changes working directory before processing
  • -f = Filename. Uses as the name of the archive
  • -h = Follow symbolic links and include the linked files
  • -P = Allows for absolute pathnames
  • -v = Verbose. Lists each file as tar reads or writes it
  • -Z = Uses utilities compress and uncompress when creating or extracting archive
  • -z = Uses the utilities gzip and gunzip (or uncompress) when creating or extracting archives

topDynamic version of ps. Constantly shows processes with most CPU usage.

  • -dn = Leave an “n” second display between new display. Default is 5 seconds.

Similar Posts