Skip to content

Instantly share code, notes, and snippets.

@thibaut-d
Last active March 2, 2019 23:42
Show Gist options
  • Save thibaut-d/8a61a6d75abc99414cb243f3112cd0b6 to your computer and use it in GitHub Desktop.
Save thibaut-d/8a61a6d75abc99414cb243f3112cd0b6 to your computer and use it in GitHub Desktop.
Another basic linux command line cheatsheet
# print the help
command --help
# ssh commands (use --help)
ssh connect using ssh -pxxxx username@xx.xx.xx.xx
scp ssh copy
rsync remote sync
# common shell commands (use --help)
ls list
cd change directory
cp copy
mv move
rm remove
mkdir make directory
touch create or reset date of creation
chown change owner
chmod change modification rights
tar archive
gzip zip (also : bzip2, 7zip)
pwd path of current working directory
ln create a link
vim text editor
# manage packages (Ubuntu)
apt-get update update the packages list
apt-get upgrade upgrade all packages
apt-get install xxx install the package xxx
apt-get remove xxx keep the package config
apt-get purge xxx also delet the package config
apt-cache policy xxx read package infos
dpkg -l | grep xxx see all packages with xxx in the name
# users
adduser username add a new user
adduser username sudo give the user sudo rights
passwd username change user password
# manage
ps print all processus
pstree idem, displayed as a tree
kill kill a processus
shutdown shutdow the server (!)
du disk usage
df disk free
top most ressources demanding processus
free free memory
echo display var content
echo $PATH display current directory
which see where a command is installed
# Redirects
less file1 > file2 copy a file
echo words >> file.txt add words to a file
ls > file.txt replace text in the file by the ls command output
ls >> file.txt append text in the file with the ls command output
less < fichier.txt get a file content
# Pipes
ps aux | grep bash launch a second command using the output of the first
# Alias
alias mycommand="command1 command2"
mycommand filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment