Show Menu
Cheatography

My Linux Cheat Sheet by

Navigation

pwd
Print Working Directory, this shows the path you are currently working on
cd
Change Directory, it can be a relative or absolute path (. is the directory itself and .. is the parent directory) Quick shotcuts
cd
goes to your home directory
cd -
goes to the last working directory
cd ~user_name
goes to the home directory of that username
ls
List contents of the directory
file
Determine file type, extensions in Linux does not necess­arily determine the purpose of the file. This command shows a brief descri­ption of the file's content.
Important facts:
- Filenames and directory names are case sensitive
- Filenames starting with an period (.) are hidden
- Do not use special characters other than period, dash and underscore

I/O Redire­ction

#####
Operators
>
Output truncate redirect
>>
Output append redirect
2>
Error redirect
#####
Commands
cat
Concat­enate
sort
Sort lines of text
grep
Print lines matching a pattern
head
Output the first specified part of a file
tail
Output the last specified part of a file
Input, Output and errors are actually sent to special files called stdin, stdout and stderr. But by default, output and errors are linked to the screen and input is attached to the keyboard.

We can redirect where output goes and where input comes from, and using that with pipelines, we can perform complex tasks.

Pipelines

Operator: |

The difference of redire­ction and pipeline is that pipeline sends output as input for another command, while redire­ction does this to files.
 

General Commands

clear
Clears the terminal screen
date
Display current time and date
cal
Display a calendar of the current month
man
Manual for commands

Manipu­lating Files and Direct­ories

cp
Copy files
-a
Copy all attributes of the original file
-i
Intera­ctive mode (ask for confir­mat­ion), default is not ask
-r
Recursive copy (required when copying entire direct­ories)
-u
Update, only overwrite if the copied files are newer
mv
Move or rename files (original file ceases to exist)
mkdir
Create direct­ories
rm
Remove (delete) files and direct­ories
-i
Prompt for confir­mation, it does not ask for default
-r
Recursive remove files, required for directory
-f
Force, ignore nonexi­stent files and do not prompt

Important Direct­ories

/
Root directory, everything begins here
/bin
contains programs for the system to boot and run (commands in bash are here too)
/dev
Devices mounted
/etc
System config­uration files, and also shell scripts that run when the system boots. Important ones:
/etc/c­rontab
- definition for automated jobs
/etc/p­asswd
- list of user accounts
/home
Home direct­ories for users
/lib
Shared libraries
/media
Removable media mount points
/root
The home directory for the root user
/tmp
Temporary files
/usr
Large directory tree, contains all the program files for regular users
/var
Directory for data that changes frequently
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet

          More Cheat Sheets by amicheletti