ssh | ssh -p 8080 username@server |
ssh into a server |
pwd | show current directory | |
touch | touch file_name |
create a file |
echo | echo "some_text" > file_name |
add text into a file |
nano | nano file_name |
text editor |
vim | vim file_name |
text editor (i to edit / :wq to save&exit) |
cat | cat file_name |
show the content of a file |
shred | shred file_name |
obfuscate the content of a file |
mkdir | mkdir folder_name |
create a folder |
cp | cp file_name file_name_2 |
copy a file |
mv | mv file_name destination_folder/ mv file_name new_file_name |
move a file to a folder or rename a file |
rm | rm file_name rm -r folder_name/ |
delete a file or a non-empty folder |
rmdir | rmdir folder_name/ |
delete a folder |
ln | ln -s file_name name_of_the_link |
create a link / with -s a soft link |
clear | cleanup console screen | |
whoami | display the current user name | |
adduser | adduser user_name |
create a new user (same as the lowlevel command useradd) |
deluser | deluser user_name |
delete a user (same as the lowlevel command userdel) |
sudo | sudo command |
execute a command with admin right |
su | su user_name |
change into another user |
exit | exit current program / sometimes need to use "q" or CTRL-C instead | |
apt | apt update |
query the package manager |
man | man package_name |
query the help for a package |
finger | finger user_name |
inspect a user |
whatis | whatis package_name |
explain what the package is |
whereis | whereis file_name |
display all the location of the file_name / shows more than which |
wget | wget remote_file |
download a remote file / pros -> can download recursively to spider a website |
curl | curl remote_file > new_remote_file_name |
download a remote file whith added options |
zip | zip archive_name file_to_archive |
archive a file or a folder |
unzip | unzip archive_name |
deflate an archive |
head | head -n 20 file_name |
show only the 20 first lines of a file |
tail | tail -n 15 file_name |
show only the 15 last lines of a file |
cmp | cmp file_1 file_2 |
compare files and tell if there is any difference |
diff | diff file_1 file_2 |
compare files and show exactly what the differences are |
sort | cat file_name | sort |
show the file_name sorted alphabetically |
find | find / -name "file_name" find . -type f -name ".*" find . -type f -empty find . -perm /a=x |
find a file_name anywhere / or in the same directory . find hidden files find empty directory find all executable files |
chmod | chmod +x file_name |
change the attribute of a file |
chown | chown user:usergroup file_name |
change the ownership of a file |
grep | ip address | grep eth0" |
find a specific element when making a query |
awk | ip address | awk '{print $2}' |
more powerfull and complex than grep, find a specific element when making a query |
ifconfig | show the IP adress and details about the network | |
ip address | show the IP adress and details about the network | |
ping | ping -c 5 ip_address ping domain_name |
ping a domain or an ip address to see if the other side is up |
netstat | netstat -tulpn |
check the ports on a machine |
ss | ss -tulpn |
check the ports of a machine / -tulpn to show only active servers |
traceroute | traceroute domain_name |
show the path to get to the website |
iptables | sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT |
add rules to the built-in firewall |
ufw | sudo ufw status |
a simplified layer over iptables |
uname | uname -a |
show details about the machine |
neofetch | sudo apt install neofetch && neofetch |
show prettier details about the machine |
cal | show a calendar | |
free | show the current memory allocation | |
df | df -H |
show the space used/available on the machine |
ps | ps -aux |
show all the processes |
top | show all the processes in a gui | |
htop | show all the processes in a prettier gui | |
kill | ps -aux | grep process_name kill -9 process_id |
kill a process with it's id |
pkill | pkill -f process_name |
kill a process with it's name |
systemctl | systemctl status |
start/stop/restart services |
history | show the typed history of the user | |
reboot | reboot reboot -f |
reboot the machine reboot forcibly |
shutdown | shutdown -h now shutdown -h +5 "message" shutdown -r +5 shutdown -c |
shutdown the machine now shutrdown in 5 minutes with a message restart the machine in 5 minutes cancel the shutdown |
Find text in file with lines -> grep -R -Hn -A1 -B1 "Text To Find" *