| Basic comands
                        
                                                                                    
                                                                                            |  | Print the contents of  file1
 ,  file2
 , ... |  
                                                                                            |  | List the contents of a directory. |  
                                                                                            |  | Use a long listing format |  
                                                                                            |  | Do not ignore entries starting with  .
 |  
                                                                                            |  |  |  
                                                                                            |  | Copy a number of files to a directory |  
                                                                                            |  |  |  
                                                                                            |  | Move a number of files to a directory |  
                                                                                            |  | Create a file. If the file already exists,  touch
  does not change it |  
                                                                                            |  | Remove a file |  
                                                                                            |  | Recursively remove all files and subdirectories in dir |  
                                                                                            |  | Print  echo
 's arguments to the standard output |  
                                                                                            |  | Print working directory |  
                                                                                            |  | Print true full path, not path of symbolic link |  
                                                                                            |  |  |  Navigating Directories
                        
                                                                                    
                                                                                            |  | Change the shell's current working directory |  
                                                                                            |  | Create a new directory |  
                                                                                            |  | Remove the directory dir if dir is empty |  Linux has a directory hierarchy starts at  /
  (root directory ). 
Directory separator is the slash ( /
 ). 
Two dots ( ..
 ) refers to the parent of a directory. 
One dot ( .
 ) refers to the current directory. Shell Globbing (Wildcards)
                        
                                                                                    
                                                                                            |  | A number of any characters |  
                                                                                            |  | A single character |  
                                                                                            |  | Specify a range.  [ab]
  can become:  a
 ,  b
 .  [a-c]
  can become:  a
 ,  b
 ,  c
 |  
                                                                                            |  | Any single character except  a
 ,  b
 ,  c
 |  Globbing is the operation that expands a wildcard pattern into the list of pathnames 
It is applied on each of the components of a pathname separately.  /
  in a pathname cannot be matched. 
If filename starts with  .
 ,  .
  must be matched explicitly. 
Wildcard patterns are not regular expressions, they match filenames, not text. Search files
                        
                                                                                    
                                                                                            |  | Search for regular expression pattern in file |  
                                                                                            |  | Case-insensitive search |  
                                                                                            |  | Print all lines that don't match |  
                                                                                            | find dir -name file -print
 | Find  file
  in  dir
  and display the pathname of it |  
                                                                                            |  | Search an index that the system builds periodically |  Display a file
                        
                                                                                    
                                                                                            |  | Display the contents of  file
  one screenful at a time |  
                                                                                            |  | Go forward one screenful |  
                                                                                            |  | Skip back one screenful |  
                                                                                            |  |  |  
                                                                                            |  |  |  
                                                                                            |  |  |  
                                                                                            |  | Display the first 10 lines of  file
 |  
                                                                                            |  | Display the last 10 lines of  file
 |  Differences between text files
                        
                                                                                    
                                                                                            |  | Print differences between two text files |  
                                                                                            |  | Print differences with color |  
                                                                                            |  | Print differences side by side |  
                                                                                            |  | View differences in context mode |  
                                                                                            |  | Ignore case differences |  
                                                                                            |  | Ignore all white space |  diff
  gives the instructions on how to change the first file to make it match the second file.
 <
  denotes lines in  file1
 .  >
  denotes lines in  file2
 .
Change command LaR
 : Add the lines in range R of the second file after line L of the first file.
 FcT
 : Replace the lines in range F of the first file with lines in range T of the second file.
 RdL
 : Delete the lines in range R from the first file so that both the files sync up at line L. Environment and Shell Variables
                        
                                                                                    
                                                                                            |  | Create a shell variable/Assign a value to a variable |  
                                                                                            |  | Appends " :dir
 " to the end of  PATH
  variable |  
                                                                                            |  | Access a variable |  
                                                                                            |  | Make  $STUFF
  shell variable into an environment variable |  
                                                                                            |  |  |  
                                                                                            |  | Prints environment variables |  Shell variables are variables whose scope is in the current shell session.
Environment variables  are shell variables which has been exported. Children processes get their own copy of the parent variables so they can never change the environment variables in their parent process. Environment variables must be  name=value
  pair.
Command path PATH
  is environment variable that contains command path  (list of system directories that the shell searches when trying to locate a command). Command-Line Editing
                        
                                                                                    
                                                                                            | CTRL-B | Move the cursor left |  
                                                                                            | CTRL-F | Move the cursor right |  
                                                                                            | CTRL-A | Move the cursor to the beginning of the line |  
                                                                                            | CTRL-E | Move the cursor to the end of the line |  
                                                                                            | CTRL-W  | Erase the preceding word |  
                                                                                            | CTRL-U | Erase from cursor to beginning of line |  
                                                                                            | CTRL-K | Erase from cursor to end of line |  
                                                                                            | CTRL-Y | Paste erased text |  
                                                                                            | CTRL-D | Stop the current standard input entry from the terminal |  |  | Getting Online Help
                        
                                                                                    
                                                                                            |  | Show manual page for  command
 |  
                                                                                            |  | Search for a manual page by  keyword
 |  
                                                                                            |  | Show manual page for  command
  from section  n
 |  
                                                                                            | Online Manual Sections |  
                                                                                            | 1 | User commands |  
                                                                                            | 2 | System calls |  
                                                                                            | 3 | Higher-level Unix programming library documentation |  
                                                                                            | 4 | Device interface and driver information |  
                                                                                            | 5 | File descriptions (system configuration files) |  
                                                                                            | 6 | Games |  
                                                                                            | 7 | File formats, conventions, and encodings (ASCII, suffixes, and so on) |  
                                                                                            | 8 | System commands and servers |  Manual pages cover the essentials, but there are many more ways to get online help. Try entering a command name followed by  --help
  or  -h
  to look for a certain option for a command Shell Input and Output
                        
                                                                                    
                                                                                            |  | Send the output of  command
  to a file |  
                                                                                            |  | Append output to the  file
 |  
                                                                                            |  | Channel a file to a program's standard input |  
                                                                                            |  | Send the standard output of  command1
   to the standard input of  command2
 |  
                                                                                            |  | Redirect the standard error ( 2
  is standard error stream ID) |  
                                                                                            |  | Redirect the all output to  file
 |  
                                                                                            |  | Send standard error to the same place as standard output |  Listing and Manipulating Processes
                        
                                                                                    
                                                                                            |  | List processes owned by root |  
                                                                                            |  | List all processes owned by you |  
                                                                                            |  | List all processes on the system |  
                                                                                            |  | Include more detailed information on processes |  
                                                                                            |  | Show full command names |  
                                                                                            |  |  |  
                                                                                            |  | Show real-time view of running system |  
                                                                                            |  |  |  
                                                                                            |  | Send  TERM
 inate signal to the process with ID  pid
 |  
                                                                                            |  | Send  STOP
  (freeze) signal to the process |  
                                                                                            |  | CONT
 inue running the process again |  
                                                                                            |  | End process with  INT
 errupt signal |  
                                                                                            |  | Terminate the process and forcibly remove it from memory |  
                                                                                            |  |  |  
                                                                                            |  | List the active jobs with their status and pid ( -l
 ) |  
                                                                                            |  | Move job that have job number  n
  to the foreground |  
                                                                                            |  | Move job that have job number  n
  to the background |  
                                                                                            |  | Run  command
  in background |  The  ps
  command has many options. Options can be specified in three different styles—Unix, BSD, and GNU. Above commands use BSD style. File Modes and Permissions
                        
                                                                                    
                                                                                            | File's mode represents the file's permission and some extra information. There is 4 parts to the mode. First character is file type. The rest contains the permissions, which break down into three sets: user, group, other, in that order. Each set can contain four basic representations: |  
                                                                                            |  | Means that the file is readable |  
                                                                                            |  | Means that the file is writable |  
                                                                                            |  | Means that the file is executable |  
                                                                                            |  | Means nothing |  
                                                                                            | Modifying Permissions |  
                                                                                            |  | Add ( +
 ) owner ( u
 ), group ( g
 ) and other users ( o
 ) read ( r
 ) permissions to  file
 |  
                                                                                            |  | Set  file
  mode to absolute permission mode  644
 |  
                                                                                            | Symbolic links A symbolic links is a file that points to another file or a directory
 |  
                                                                                            |  | Create a symbolic link from  target
  to  linkname
 |  Archiving and Compressing Files
                        
                                                                                    
                                                                                            |  |  |  
                                                                                            | gunzip file.gz
  or  gzip -d
 | Uncompress  file.gz
  and remove the suffix |  
                                                                                            | tar cf archive.tar file1 file2
 | Create ( c
 ) an archive name ( f
 )  archive.tar
  contains  file1
 ,  file2
 |  
                                                                                            |  |  |  
                                                                                            |  | List the contents ( t
 ) of  archive.tar
 |  
                                                                                            | gunzip -c file.tar.gz | tar xf -
 zcat file.tar.gz | tar xf -
 tar zxf file.tar.gz
 | Unpack compressed archive  file.tar.gz
 |  gunzip -c
  uncompresses archive then sends the result to standard output.
 tar xf -
  uses standard input instead of a given filename. Some subdirectories in root
                        
                                                                                    
                                                                                            |  | Contains ready-to-run programs including most of the basic Linux commands |  
                                                                                            |  | Contains device files |  
                                                                                            |  | Core system configuration directory that contains the user password, boot, device, networking, and other setup files |  
                                                                                            |  | Holds personal directories for regular users |  
                                                                                            |  | Holds library files |  
                                                                                            |  | Provices system statistics |  
                                                                                            |  | Provides a device and system interface |  
                                                                                            |  | Place for system management programs |  
                                                                                            |  | Storage area for temporary files |  
                                                                                            |  | Other bulk of Linux system |  
                                                                                            |  | Where programs record runtime information |  
                                                                                            |  | Contains kernel boot loader files |  
                                                                                            |  | A base attachment point for removable media |  
                                                                                            |  | This may contain additional third-party software |  
                                                                                            | /vmlinuz
  or  /boot/vmlinuz
 | Kernel location |  The reason that the root directory does not contain the complete system but other parts stored in  /usr
  is primarily historic—in the past, it was to keep space requirements low for the root | 
            
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets