UNIX Command Reference

From HaFrWiki
Revision as of 15:58, 12 September 2018 by Hjmf (talk | contribs) (P)
Jump to: navigation, search

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

UNIX [1] command line reference links to explanations. The list below is an excerpt from the rich command line set and will be changed constantly.


A

Command Description Extra
ack A better than grep implementation. See also UNIX ack NCyg
admin Administer SCCS files. NCyg
apt Package managing system NCyg
ar Maintain, modify, and extract from archives. Now largely obsoleted by tar. Cyg
as GNU assembler tool. Also known as Gas. Cyg
at Single-time command scheduler Cyg
Pattern scanning and processing language.
See also AWK.
Cyg.

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


B

Command Description Extra
banner Creates ascii art version of an input string for printing large banners Cyg
basename Returns the final component of a path Cyg
batch Runs jobs when the system load level permits NCyg
bc An arbitrary precision calculator language with syntax similar to the C programming language. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


C

Command Description Extra
cal Displays a calendar NC
cat Concatenates files to standard output.
Example:cat fileIn | sort -u > FileOut.uniq
Cyg
cc C-compiler Cyg
cd Changes the directory Cyg
chmod Change the permissions of a file or directory. See the table below for all combinations/settings.

The roles are:

  • u for users
  • g for group
  • o for others
  • a all which is used in chmod as the combination for ufo'.
# rwx Permission rwx
7 rwx full 111
6 rw. read and write 110
5 r.x read and execute 101
4 r.. read only 100
3 .wx write and execute 011
2 .w. write only 010
1 ..x execute only 001
0 ... none 000

So:

Command Result Description
chmod u+x
chmod 100
---x------ Gives the User permission to eXecute
chmod u+r,g+x
chmod 510
-r-x--x--- Gives extra read access (existing access 'execute' to the user, and grant execute access to the group.
chmod u-rx
chmod 010
------x--- Removes the read and execute from user, without changing the granted group access.
chmod a+x
chmod 111
---x--x--x Grants execute rights to all.
chmod --reference   Make the file permissions of file2 exactly the same as file 1.
Cyg
chown Change the owner of a file or directory Cyg
cksum Print the CRC checksum and bytecount of a file (see also MD5) Cyg
clear Clears the content of the screen Cyg
cmp Compares two files byte for byte Cyg
comm Sorts two files and compare them line for line Cyg
cp Copies a file or directory to another location.
To copy directories recursive use: cp -r xxx yyy
Cyg
crontab Schedules commands to be executed periodically. NC
crypt Crypts or decrypts a data NC
csh C shell (csh) is a Unix shell developed by Bill Joy for the BSD Unix system. NC
csplit csplit separates a file into sections and place the sections into files names xx00 through xx99. Cyg
ctags Generate tags file summarising location of objects in source files. NC
cut cut extract a certain range of characters from a line, usually from a file. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


D

Command Description Extra
date Print or set the system date and/or time Cyg
dbx (System V and BSD) Symbolic debugger. NC
dc Reverse-Polish desk calculator which supports unlimited precision arithmetic Cyg
dd Converts and copies a file (Disk Dump).
A powerful low-level tool for cloning hrd disks.
Cyg
df Displays the amount of disk space used and available on the filesystems accessible to a user. Cyg
diff Reports the line difference between 2 files. Cyg
diff3 Compares three files and report the differences. Cyg
dircmp Compares the contents of files between two directories Cyg
dirname Strips non-directory suffixes from a path Cyg
du estimate the file space usage Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


E

Command Description Extra
echo Print to standard output Cyg
ed Standard text editor. See also ex. NC
env Show environment variables; run a program with altered environment variables Cyg
eqn Part of the troff suite of Unix document layout tools, eqn is a preprocessor that formats equations for printing. A similar program, neqn, accepted the same input as eqn, but produced output tuned to look better in nroff. eqn was created by Brian Kernighan and Lorinda Cherry. Cyg
ex Advanced version of the standard Unix editor ed, Cyg
expr Evaluates an expression Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


F

Command Description Extra
factor (num) Produce the prime factors of num. Cyg
fc Processes the command history list Cyg
fgrep Simplified pattern matching (synonym for "grep -F") Cyg
file Determine the type of a file, (See also stat) Cyg
find Search for files through a directory hierarchy.
One of the most complicated UNIX commands, See also GNU Find.
An alternative GUI find is SearchMonkey.
See also xargs, and the Examples.
Cyg
finger Displays data about one or more users, including information listed in the files. Also the shell you are currently using (finger -m <username>) Cyg
fit fmt fills and joins text, producing lines of roughly the same length. Cyg
fold Fold breaks the lines of the named files so that they are no wider than the specified width. Cyg
ftp ftp transfers files to and from remote network site hostname. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


G

Command Description Extra
Gedit gedit is the official text editor of the GNOME desktop environment. Is also available for Windows, MacOS. Ubuntu
getopts Retrieves options and option-arguments from a list of parameters. Cyg
gprof Display call-graph profile data of C programs. Cyg
grep grep takes a regular expression on the command line, reads standard input or a list of files, and outputs the lines containing matches for the regular expression. Cyg
groups Show the groups that user belongs to (default is your groups). Groups are listed in /etc/passwd and /etc/group. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


H

Command Description Extra
head Output the first parts of a file. Cyg
help Display helpful information about builtin commands. Cyg
hostid Print the hexadecimal ID number of the host machine. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


I

Command Description Extra
iconv Convert the encoding of the specified files Cyg
id Prints the UID of the account of which the program is executed by. Cyg
install Install] copies files and set attributes Cyg
ipcrm Removes a message queue, semaphore set or shared memory id. Cyg
ipcs Provides information on IPC facilities Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


J

Command Description Extra
join Joins lines of two files on a common field Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


K

Command Description Extra
kill Sends a message normaly a termination signal (message) to a program Cyg
ksh Korn shell, standard shell on many proprietary Unix systems, powerful successor to the Unix Bourne shell (sh), written by David Korn, NC

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


L

Command Description Extra
ld Program linker Cyg
less Shows the content of a file on the terminal screen. Cyg
ln Creates symbolic links. Cyg
login Logs in to the system Cyg
logname Logname prints the user login name Cyg
lp Prints a file (on a line printer) NC
ls Lists segments or lists files (directories). Examples:
  • Show symbolic links: ls -l . | grep ">"
  • Alias example for showing all information: alias la='ls -al '
  • Alias example for shwing alias lr='ls -l | wc'

The meaning of all fields of ls -Al common known as the alias la.

Type User Group Other
ldc r w x r w x r w x
[1] [2] [3] [4]
  • [1] The type of the entry, a symbol link (l), a directory (d) or a character file (c)
  • [2] The user rights for read, write and execute.
  • [3] The group rights for read, write and execute.
  • [4] The other rights for read, write and execute.

The full signature of the la -Al can be:

lrwxrwxrwx owner group 12345 Feb 26 07:08 file1

Meaning:

  1. owner the name of the owner of the file, use the chown command to change (i.e.: chown root file)
  2. group, the group to which the file belongs, use the chown command to change (i.e. chown :friends file).
  3. 12345, the size of the file, edit the file to change
  4. Feb 26 07:08, the creation date of the file, use touch to change
  5. file1, the filename of the file, use mv to change (i.e. mv file1 file2).
Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


M

Command Description Extra
mail Unix standard mail client.
Examples Mail
NC
mailx Improved mail client NC
make Automates builds.
See the GNU Make Wiki page.
Cyg.
man Displays extensive documentation on commands Cyg
mkdir Makes a (sub)directory Cyg
more Displays the named files on a terminal, one screenful at a time. Cyg
mv Moves a file or directory from one place to another. Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


N

Command Description Extra
nice maps to a kernel call of the same name. Cyg
nl Numbers the lines of a file. Cyg
nohup Run a command with immunity to hangups outputting to non-tty Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


O

Command Description Extra

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


P

Command Description Extra
Runs periodic system functions
Example: sudo periodic daily weekly monthly
 
Process Status displays the currently-running processes. Example to show if cron is running:
ps -el | grep cron
 

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


Q

Command Description Extra

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


R

Command Description Extra
replace
KSH replaces characters/text in a string. This KSH option is a feature of the shell. See the kWh manual.
Examples are:
  • Replaces 1st occurrence of text in string: ${string/find/replace}
  • Replaces all occurrences of text in string: ${string//find/replace}
KSH Only.
rm Removes a file (file list).  
rsync rsync synchronizes files and directories from one location o another while minimizing data transfer by using the delta encoding when appropriate.
For examples look at Unix rsync
 

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


S

Command Description Extra
sh Bourne shell, the standard Unix shell  
scp Secure Copy or SCP is a means of securely transferring computer files between a local and a remote host or between two remote hosts, using the Secure Shell (SSH) protocol.
  • scp SourceFile user@host:directory/TargetFile
  • scp user@host:folder/SourceFile TargetFile
See also Secure copy for secure copy without Password.
Sed reads text input, line by line, either from a file or a stream, into an internal buffer called the pattern space. Each line read starts a cycle. To the pattern space, sed applies one or more operations which have been specified via a sed script. sed implements a programming language with about 25 commands that specify the operations on the text. When the sed script ends, sed outputs the pattern space, and reads the next line into the pattern space, starting a new cycle.  
Split a large file into smaller parts. Examples:
  • split -b 22 newfile.txt new
    Split the file "newfile.txt" into three separate files called newaa, newab and newac each file the size of 22.
  • split -l 300 file.txt new
    Split the file "newfile.txt" into files beginning with the name "new" each containing 300 lines of text each
  • split -b 720mb file.zip parts
    Split the file "file.zip" into files beginning with the name "parts" each containing 720Mb.

In windows combine the file using:

  • copy /b file1+file2 result
 
strings Shows all string in a binary dump.
  • strings dd_onbz.dmp | less -f
 
sudo The sudo command is a program for some UNIX and Unix-like computer operating systems that allows users to run programs with the security privileges of another user (normally the superuser, or root).
See also: Sudo manpage, Ubuntu Karmic sudo manpage and SuDo Home Page [2].
 
sysv-rc-conf sysv-rc-conf gives an easy to use interface for managing etc/rc{runlevel}.d/ symlinks. The interface comes in two different

flavors, one that simply allows turning services on or off and another that allows for more fine tuned management of the symlinks. It’s a replacement for programs like ntsysv(8) or rcconf(8).
See also Linux startup process.

Ubuntu

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


T

Command Description Extra
tail Tails to see and follow (-f) the lines of a logfile. Cyg
Test The test command in Unix evaluates the expression parameter. In some shells such as FreeBSD sh(1) it is a shell builtin, even though the external version still exists.

In the second form of the command, the [ ] (brackets) must be surrounded by blank spaces. This is because [ is a program and POSIX compatible shells require a space between the program name and its arguments. One must test explicitly for file names in the C shell. File-name substitution (globbing) causes the shell script to exit.

tr Translate, squeeze, and/or delete characters from standard input, writing to standard output.
Example: tr -cs "[:alpha:]" "[\n*]" < input > output
Cyg

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


U

Command Description Extra
uptime Print how long the system has been running  

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


V

Command Description Extra
vi vi is a family of screen-oriented text editors. See the internal wiki page on vi. Cyg
visudo visudo edits the sudoers file in a safe fashion, analogous to vipw.

Visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. If the sudoers file is currently being edited you will receive a message to try again later.

Ubuntu

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


W

Command Description Extra
wc Unix Word Count, showing the number of lines, words and bytes. Example:

wc foo bar

Cygwin
Whois Who is gives the owner/user of an IP-address. See the Whois-wiki page for detailed information on whois and the available free and paid services. Cygwin

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


X

Command Description Extra
xargs reads items from the standard input, delimited by blanks or newlines and executes the command one or more times.
xargs is useful when passing large number of arguments to a command. See also Find and the examples.
 

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


Z

Command Description Extra
ZIP managess package and compress (archive) files  

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


See also

top

Reference

top

  1. UNIX is a computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna. Today the term Unix is used to describe any operating system that conforms to Unix standards, meaning the core operating system operates the same as the original Unix operating system. (Wikipedia).
  2. Sudo Home Page contains information, documentation and downloads of the SuDo command and usage.