Cheatography
https://cheatography.com
Cheat sheet for the LinkedIN course about Linux Command Line
General Command Syntax
Command |
Option(s) |
Argument(s) |
ls |
-ahl |
/usr/bin |
sort |
-u |
users.txt |
grep |
-i "needle" |
heystack |
Commands are programs that take a particular action
Options tell the command how to operate
Arguments tell the command what to operate on
Finding Help for Commands
man |
argument |
argument |
--help |
apropos |
functionality search |
Useful Keyboard Shortcuts
Tab |
Tab completion |
Ctrl - A |
Move to beginning of line |
Ctrl - E |
Move to end of line |
Ctrl - Left arrow |
Move left one word |
Ctrl - Rig arrow |
Move right one word |
Ctrl - U |
Delete from cursor to line start |
Ctrl - K |
Delete from cursor to line end |
Ctrl - Shift - C |
Copy selected text to clipboard |
Ctrl - Shift - V |
Paste text from clipboard |
Up arrow |
Recall previous command |
Down arrow |
Scroll previous command |
Ctrl - R |
Search command history |
Ctrl - C |
Cancel command |
Commands for File Information
Command |
Option(s) |
Argument(s) |
Description |
file |
|
argument |
Determine file type |
stat |
|
argument |
Display file status |
Notable File System Directories
/ |
File system root |
/home |
User home directories |
/root |
Root user's home directory |
/etc |
Common configuration files |
/bin, /sbin |
Common programs or commands |
/lib |
Shared libraries and modules |
/mnt, /media |
Standard location for mounting other file systems |
/dev, /proc, /sys |
Kernel and system information |
Paths in Linux
/ |
Absolute path |
. |
Current working directory |
.. |
Parent directory |
~ |
Current user's home directory |
\ - space |
Equivalent to space key |
The File System
cd |
Change the shell working directory |
pwd |
Print the name of File system root: / User home directories: /home Root user's home directory: /root |
ls |
The File System
Command |
Option(s) |
Argument(s) |
Description |
cd |
available |
new directory |
Change the shell working directory |
pwd |
available |
|
Print the name of the current working directory |
ls |
-lh |
directory |
List information about the files |
Working with Directories and Files
Command |
Option(s) |
Argument(s) |
Description |
mkdir |
available |
directory(ies) |
Create the directory(ies)Create the directory(ies) |
rmdir |
available |
directory(ies) |
Remove the directory(ies), if they are empty |
cp |
available |
source - destination |
Copy source to destination |
mv |
available |
source - destination |
Move source to destination |
rm |
-r |
file(s) |
Remove the file(s) (recursively) |
find |
-name |
directory - "expression*? |
Find directory or file by name |
Search for Text
Command |
Option(s) |
Argument(s) |
Description |
grep |
options |
"pattern*? file name |
Search for patterns in file |
Tools for Text
Command |
Option(s) |
Argument(s) |
Description |
cat |
available |
file name |
Concatenate to standard output |
head |
available |
file name |
Print the first number of something |
tail |
available |
file name |
Print the last number of something |
Tools for Working with Text
Command |
Description |
awk |
Often used to extract specific text from a file according to rule |
sed |
Often used to modify text in a command pipeline or in place |
sort |
Often used to sort text |
Vim and nano are very popular text editors in CLI
|
|
Hard and Symbolic Links
Command |
Option(s) |
Argument(s) |
Description |
ln |
-s |
source file link name |
Creates a soft link |
ln |
|
source file link name |
Creates a hard link |
- A hard link points to specific data (by inode) on the disk
- A soft link or symbolic link (symlink) points to another file
File Permissions
User |
Group |
Others |
Description |
rwx |
rwx |
rwx |
Up to three letters indicate the permissions for the file or directory |
|
Command |
Option(s) |
Argument(s) |
Description |
chmod |
octal or symbolic change |
file or directory |
Changes the mode of the file or directory |
chown |
new owner |
file or directory |
Changes the owner of the file or directory |
chgrp |
new group |
file or directory |
Changes the group of the file or directory |
r: read (value of 4)
w: write (value of 2)
e: execute (value of 1)
u: user
g: group
o: others
a: all
Two methods to represent permissions:
- Octal (like 755, 644, 777)
- Symbolic (like a=r, g+w, and o-x)
Tape Archives and Data Compression
Command |
Option(s) |
Argument(s) |
Description |
tar |
-cvf |
file name.tar directory |
Creates a tape archive |
tar |
-caf |
file name.tar.gz/tar.bz2 directory |
Creates a compressed tape archive, the compression type depends on the extension |
tar |
-xf |
file name -C target directory |
Extracts a compressed tape archive inside a certain directory |
zip |
-r |
file name directory to compress |
Compresses a directory |
unzip |
|
file name -d target directory |
Extracts a directory |
Formats for compressed .tar files are: .tar.gz, .tgz, .tar.bz2
Superuser Rights
sudo + command |
Executes the command with superuser rights (requires user password) |
sudo + -s |
Activates superuser rights for a period of time |
sudo + -k |
Gives up superuser rights |
Environment Variables and PATH
env |
Set some attributes in the environment |
which |
Locate a command |
~/.bash_profile |
Bash profile (create with command nano) |
Inside nano, write:
PATH = "$PATH : /my/custom/path : /some/other/path"
Redirection
Stream |
Number |
Usage |
Standard Input (stdin) |
0 |
Text input |
Standard Output (stdout) |
1 |
Text output |
Standard Error (stderr) |
2 |
Error text |
|
command |
number> |
file name |
Redirects the output to the file |
command |
number>> |
file name |
Appends the output to the file |
Information About Linux Distribution & Hardware
Command |
Description |
ls -l /etc/*release |
List of the files that contain information about the release |
cat /etc/*release |
Shows information about the two files in the release folder |
uname -a |
Show information about Linux Kernel |
uname -r |
Shows only the version of the Linux Kernel |
free -h |
Shows how much memory the system has |
cat /proc/cpuinfo |
Shows how much CPU the system has |
lscpu |
Shows more comprehensive information about the system's CPU |
df -h |
Shows how much storage the system has |
Install and Update Software
apt search search |
Looks for packages whose description match the search term |
apt show package |
Displays information about the package |
sudo apt update |
Retrieve an updated list of the packages from the repositories before installing new software or upgrading the software package |
sudo apt install package |
Install the package |
sudo apt upgrade |
Upgrade the software package |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets