Cheatography
https://cheatography.com
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 necessarily determine the purpose of the file. This command shows a brief description 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 Redirection
##### |
Operators |
> |
Output truncate redirect |
>> |
Output append redirect |
2> |
Error redirect |
##### |
Commands |
cat |
Concatenate |
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 redirection and pipeline is that pipeline sends output as input for another command, while redirection 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 |
Manipulating Files and Directories
cp |
Copy files -a
Copy all attributes of the original file -i
Interactive mode (ask for confirmation), default is not ask -r
Recursive copy (required when copying entire directories) -u
Update, only overwrite if the copied files are newer |
mv |
Move or rename files (original file ceases to exist) |
mkdir |
Create directories |
rm |
Remove (delete) files and directories -i
Prompt for confirmation, it does not ask for default -r
Recursive remove files, required for directory -f
Force, ignore nonexistent files and do not prompt |
Important Directories
/ |
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 configuration files, and also shell scripts that run when the system boots. Important ones: /etc/crontab
- definition for automated jobs /etc/passwd
- list of user accounts |
/home |
Home directories 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 |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by amicheletti