- Kali, linux Commands
Linux Commands Cheat Sheet#
1. File and Directory Management#
-
ls
List files and directories.
Example:ls
-
ls -l
List files with detailed information.
Example:ls -l
-
mkdir
Create a new directory.
Example:mkdir new_folder
-
rmdir
Remove an empty directory.
Example:rmdir empty_folder
-
rm
Delete files or directories.
Example:rm file.txt
-
cp
Copy files or directories.
Example:cp source.txt destination.txt
-
mv
Move or rename files.
Example:mv old_name.txt new_name.txt
-
pwd
Show the current directory.
Example:pwd
2. File Viewing#
-
cat
Display file contents.
Example:cat file.txt
-
less
View file with pagination.
Example:less file.txt
-
head
Display the first 10 lines of a file.
Example:head file.txt
-
tail
Display the last 10 lines of a file.
Example:tail file.txt
-
tail -f
Follow updates to a file (e.g., log file).
Example:tail -f log.txt
3. File Permissions and Ownership#
-
chmod
Change file permissions.
Example:chmod 755 script.sh
-
chown
Change file ownership.
Example:chown user:group file.txt
-
ls -l
View file permissions and ownership.
Example:ls -l
4. Searching#
-
grep
Search for a pattern in a file.
Example:grep "search_term" file.txt
-
grep -r
Search recursively in directories.
Example:grep -r "search_term" directory/
-
find
Locate files by name or criteria.
Example:find /path -name "file.txt"
-
locate
Search files quickly using a pre-built database.
Example:locate file.txt
-
updatedb
Update the database forlocate
.
Example:sudo updatedb
5. Disk Usage#
-
df -h
Show free disk space in human-readable format.
Example:df -h
-
du -h
Show disk usage of files/directories.
Example:du -h directory/
6. Networking#
-
ip addr
Display network interfaces and IP addresses.
Example:ip addr
-
ping
Test connectivity to a host.
Example:ping google.com
-
netstat
View network connections.
Example:netstat -tuln
-
nslookup
Query DNS records for a domain.
Example:nslookup example.com
-
traceroute
Trace the route to a host.
Example:traceroute google.com
7. User Management#
-
adduser
Add a new user.
Example:sudo adduser username
-
deluser
Remove a user.
Example:sudo deluser username
-
whoami
Show the current logged-in user.
Example:whoami
-
who
Show logged-in users.
Example:who
8. Process Management#
-
ps aux
List all running processes.
Example:ps aux
-
top
Display real-time process usage.
Example:top
-
kill
Terminate a process by PID.
Example:kill 1234
-
killall
Terminate processes by name.
Example:killall firefox
9. Package Management (Debian-based Systems)#
-
apt update
Update package lists.
Example:sudo apt update
-
apt upgrade
Upgrade installed packages.
Example:sudo apt upgrade
-
apt install
Install a package.
Example:sudo apt install curl
-
apt remove
Remove a package.
Example:sudo apt remove package_name
-
apt search
Search for a package.
Example:apt search package_name
10. System Monitoring#
-
uname -a
Display system information.
Example:uname -a
-
free -h
Show memory usage in human-readable format.
Example:free -h
-
uptime
Show system uptime.
Example:uptime
[Crusveder]