0% found this document useful (0 votes)
24 views

1.1 Linux Cheatsheet

This document lists Linux commands for navigating directories, manipulating files and directories, viewing file contents, installing and managing packages, managing users and groups, system monitoring, networking tasks, and more. It provides examples of using each command along with options to customize the behavior.

Uploaded by

Samir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

1.1 Linux Cheatsheet

This document lists Linux commands for navigating directories, manipulating files and directories, viewing file contents, installing and managing packages, managing users and groups, system monitoring, networking tasks, and more. It provides examples of using each command along with options to customize the behavior.

Uploaded by

Samir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Command

pwd
ls
ls -l
ls -lh
ls -a
ls -R
ls /home
ls -a -l / ls -al
ls -r
ls test
ls /test

cd
cd ..
cd ../..
cd /home

touch test.txt
rm test.txt
mkdir test
mkdir -v test
rmdir test
rm -r test
rm *

mv test.txt ..
mv test.txt test2.txt
mv test /home
cp test.txt ..
cp test.txt test2.txt
cp test.txt /home
cp -r test /home

cat test.txt
cat > test.txt
cat 1.txt 2.txt > 3.txt
cat test.txt | grep bird
cat test.txt | grep "bird\|dog"
vim test.txt
nano test.txt

more test.txt
more +2 test.txt
more +"/cat" test.txt
less -p "cat" test.txt
less -N test.txt
echo "TEST"
echo $(( 1+1 ))

head test.txt
head -10 test.txt
tail test.txt
tail -10 test.txt
tail -f /var/log/syslog

zip -r test.zip test.txt


unzip test.zip
zip -r test.zip test test.txt -P 11
rar a test.rar test.txt
unrar e test.rar
rar a test1.rar test
rar a test1.rar test/
chmod
chmod +x test.txt
chmod -x test.txt
chmod 0 test.txt
chmod 666 test.txt

sudo apt-get install nano


sudo apt-get install nano vim
sudo apt-get remove nano
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

sudo COMMAND
sudo su
exit
su user1
su
passwd
sudo passwd user1

sudo adduser user1


sudo userdel user1
sudo userdel --r user1
su user1 -c "ls"
cat /etc/passwd
sudo cat /etc/shadow

usermod -L user1
sudo usermod -U user1
sudo groupadd group1
sudo usermod -G group1 user1
cat /etc/group
sudo groupmod -n group2 group1
sudo groupdel new_group

uname -a
uname -n
hostname
uptime
date
clear

command --help
info command
whatis command
whereis command
whoami
history
history -c

shutdown
shutdown -c
shutdown now
shutdown 11:00
shutdown +10
reboot
halt
poweroff

du
du /etc -h
du -sh
df -h
free -m

top
top -d 5
top -p PID
top -i
htop
ps fax
kill PID
kill -9 PID

ifconfig
ping
ping -c 5
ping -s 100
traceroute
telnet IP_ADD
ssh USER@IP_ADD

host
whois
netstat
wget
curl -O
Description
Show the current directory full path
Show the all files and directories in current path (“dir” in Windows )
Show detailed information like owner, mode, size, change date
Show size as more readable like in KB, MB, GB
Show hidden files
Show also sub files inside of directory
Show specific path’s inside
Same result, different usage
Show files in reverse order
Path in current directory
Full path from root directory

Change Directory
Go back to upper directory
Go back to 2 upper directory (Can be more with ../../../..)
Go to another directory with writing the full path

Create a file
Remove a file
Create a directory
-v option shows details of the process
Remove a directory, if directory has no content
Remove directories and their contents recursively
Remove only all files in current directory, directory is not removed

Move file to upper directory


Rename the file
Move directory with its content to another directory
Copy file to upper directory
Copy file with new name
Copy file to a directory
Copy directory recursively with its content to another directory

Show file content


Add content to file.(Overwrite, not append, Create if no file)
Copy files content in order and add to a new file
Search specific text in file
Search multiple letters with "or - \|" sign
Create/Modify text file
Create/Modify text file

Show file
Start to show file from 2nd line
Start to show file with a specific letter
Find all specific letter in the file
Open file with line number
Enter content in Terminal (Like prompt in python)
Calculate integers

Show first lines of text file


Show first 10 lines of file
Show the last lines of the text file
Show last 10 lines of the file
Show last lines of file, Update the file instantly

Zip the file to test.zip (r - recursively)


Unzip zip file
Set password for zip file
Rar the file (a - Add files to archive)
Unrar file ( e - Extract files without archived paths)
Archive directory with its content
Archive directory content only (Not included directory)
Change access permission to files or directories
Give execute permission from all users
Remove execute permission from all users
Remove all permission for all users
Add read/write for all users

Install a package
We can add multiple packages
Remove package
Update package index or list
Upgrade all installed packages to latest version
Remove installed packages dependencies

Temporarily enter root user for a specific command and exit


Permanently enter root user
Exit from current user
Switch user to user1
Switch user to root user
Change password of current user
Change password for user1

Add new user


Remove user, but not delete user files
Remove user with it's all files
Run “ls” command in user1 home directory ( -c : command)
Show all users and user informations
Show all users and their encrypted passwords

Lock user - user cannot enter or use its account.


Unlock user
Create new group
Add user to group
Check groups
Change group name from group1 to group2
Delete group

Show details of Operation System


Show hostname of device
Show hostname of device
Show the uptime of device
Show system date
Clear all in the terminal screen

Show usage of specific command (nano --help)


Show detailed documentation of command (info nano)
Show the command description (whatis nano)
Show the directory of command (whereis nano)
Show current user
Show the commands that run before. Can be used with "| grep"
Delete all history commands

Shutdown after 1 minute


Cancel shutdown task
Shutdown immediately
Shutdown at 11:00
Shutdown 10 minutes later
Reboot device
System opened, cpu ve processes will be stopped
Shutdown device. In addition to halt, system will be stopped

Show disk usage of current directory


Show disk usage of specific directory with size type as KB, MB, GB
Total usage of current directory
Show Used/Available Memory in all file systems in KB, MB, GB
Show total memory usage (-m: as MB based, -h: as KB, MB, GB based)

Show CPU and Memory usage of all processes


Update in every 5 seconds
Show process with specific PID number
Show only active processes that changes everytime
Show CPU and Memory usage. Better view than top command
Show processes in terminal and system
Stop process with Process ID
Force to stop process

Show network information of interfaces, IP, netmask, gateway


Ping IP address - continues ping
Set ping count
Set ping packets size as bytes
Find all hops between source and target device
Make telnet connection to remote device
Make SSH connection to remote device

Find IP address of a website


Show domain information of websites
Show network information. Show all sockets in system.
Download file from internet
Download file from internet

You might also like