Unix is a family of computer operating systems that derive from the original Unix from Bell Labs.
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don't insist on interactive input.
Locations in home
|$HOME/etc||System configuration for local binaries|
|$HOME/games||Local game binaries|
|$HOME/include||Local C header files|
|$HOME/lib64||Local 64-bit libraries|
|$HOME/man||Local online manuals|
|$HOME/sbin||Local system binaries|
|$HOME/share||Local architecture-independent hierarchy|
|$HOME/src||Local source code|
|List files in the directory|
|Remove file or directory(-r)|
|Copy file or directory(-r)|
|Move file or directory|
|Count words in file|
|Read the manual|
|Reads content of files sequentially|
|Make new directory|
|Show system date|
|Searches text for matches of a regular expression|
|Displays the tail end of a file or data|
usage statement is a printed summary of how to invoke a program from a shell prompt. It includes a description of the possible command-line arguments that the program might take. If a program is called with incorrect command-line arguments, it should print a usage statement to the terminal.
Usage statements should be printed to "standard error"
stderr, and not to
stdout. Your usage statement should contain:
The name of the program
Every non-optional command-line argument your program takes
Every optional command-line argument your program takes
Any extra descriptive material that the user should know about.
- The usage statement should always begin with the literal word
usagein lower case, followed by a colon and a space, followed by the rest of the usage message. So, the usage message starts with
- Every command-line argument in the usage statement should be a single word, with no spaces.
- The word representing a particular command-line argument should be descriptive. It should say what the command-line argument is supposed to represent, at least in general terms. Do not separate successive command-line arguments with commas or semicolons; just separate them with single spaces.
Optional arguments should always be surrounded by square brackets. Do not use square brackets for any other purpose in usage messages. Don't use anything but square brackets for this purpose. Square brackets mean that an argument is optional, always.
Optional "flags" (arguments that change the way the program works)
should start with a dash. Very often (but not always) they will have a name
which is a dash followed by a single letter, which identifies what it is.
Here's an example, which is a greatly simplified version of the usage message
for the Unix
ls program which lists files:
usage: ls [-a] [-F]
This program is called
ls and can be called with
no arguments, with one optional argument (
ls -a or
ls -F) or with two optional arguments
ls -a -F). In this particular case, the
-a optional argument says to list hidden files as
well as normal ones, and
-F changes the way the
output of the program is formatted.
Note that each optional argument gets its own set of square brackets.
If an optional "flag" argument itself has arguments, put them inside the square brackets.
You shouldn't hard-code the program name into your program's source code.
It won't make any difference in how it's displayed, but if you change the
name of your program and don't change your usage message the usage message
will be invalid. Instead, you should write your code so that the program
name gets inserted into the usage message before printing. In C, the program
argv (the first element of the
argv array) whereas in python it's
Copy a file
$ cp readme.txt documents/
Duplicate a file
$ cp readme.txt readme.bak.txt
Copy a directory
$ cp -a myMusic myMedia/
Duplicate a directory
$ cp -a myMusic/ myMedia/
Move a file
$ mv readme.txt documents/
Move a directory
$ mv myMedia myMusic/
Rename a directory
$ mv myMedia/ myMusic/
$ rsync -a /images/ /images2/
Create a new file
$ touch 'new file'
Create a new directory
$ mkdir 'untitled folder'
Show file/directory size
$ du -sh node_modules/
Show file/directory info
$ stat readme.md
Open a file with the default program
$ xdg-open file # on Linux
Zip a directory
$ zip -r archive_name.zip folder_to_compress
Unzip a directory
$ unzip archive_name.zip
Peek files in a zip file
$ unzip -l archive_name.zip
Remove a file
$ rm my_useless_file $ rm -r my_useless_folder
List directory contents
$ ls my_folder # Simple
Tree view a directory and its subdirectories
Find a stale file
$ find my_folder -mtime +5
View content of a file
$ cat apps/settings.py
Search for a text
$ grep -i "Query" file.txt
Make applications in ~/bin/ available from anywhere
~/.bashrc, when finished run
|Send output from |
|Receive input from file |
|Connect output of |
|Debug, Delete, Directory||Quiet, Quit|
From each according to their stdout to each according to their stdin