Linux Cheat Sheet
Basic Commands
pwd: Print the current working directory.pwdls: List files and directories.ls -lacd: Change directory.cd /path/to/directorymkdir: Create a new directory.mkdir myfolderrmdir: Remove an empty directory.rmdir myfoldercp: Copy files or directories.cp file.txt /path/to/destination/
cp -r folder /path/to/destination/mv: Move or rename files or directories.mv file.txt /path/to/destination/
mv oldname.txt newname.txtrm: Remove files or directories.rm file.txt
rm -r foldertouch: Create a new, empty file.touch newfile.txtcat: Display the content of a file.cat file.txtnano/vim: Edit files with text editors.nano file.txt
vim file.txt
System Information
uname -a: Display system information.uname -atop: Display running processes and system resource usage.topdf -h: Display disk space usage.df -hfree -h: Display memory usage.free -huptime: Show how long the system has been running.uptimewhoami: Display the current user.whoami
File Permissions
chmod: Change file permissions.chmod 755 file.txt
chmod u+x script.shchown: Change file owner and group.sudo chown user:group file.txt
Process Management
ps aux: List all running processes.ps auxkill: Terminate a process by PID.kill 1234killall: Terminate all processes by name.killall firefoxbg: Resume a suspended job in the background.bgfg: Bring a background job to the foreground.fg
Networking
ifconfig: Display network interfaces and IP addresses.ifconfigping: Check connectivity to a host.ping google.comcurl: Fetch content from a URL.curl http://example.comwget: Download files from the web.wget http://example.com/file.zip
Package Management (Debian/Ubuntu)
apt-get update: Update package lists.sudo apt-get updateapt-get upgrade: Upgrade all installed packages.sudo apt-get upgradeapt-get install: Install a package.sudo apt-get install package_nameapt-get remove: Remove a package.sudo apt-get remove package_nameapt-get autoremove: Remove unnecessary packages.sudo apt-get autoremove
User Management
adduser: Add a new user.sudo adduser usernamepasswd: Change a user's password.passwd usernamedeluser: Delete a user.sudo deluser usernameusermod: Modify a user's account.sudo usermod -aG groupname username
Disk Management
fdisk -l: List all partitions.sudo fdisk -lmount: Mount a filesystem.sudo mount /dev/sdX /mntumount: Unmount a filesystem.sudo umount /mntfsck: Check and repair a filesystem.sudo fsck /dev/sdX
Searching and Finding Files
find: Search for files in a directory hierarchy.find /path -name filenamegrep: Search for a pattern within files.grep "pattern" file.txt
grep -r "pattern" /pathlocate: Find files by name quickly.locate filename
Archiving and Compression
tar: Create and extract tar archives.tar -czvf archive.tar.gz /path/to/directory
tar -xzvf archive.tar.gzzip/unzip: Compress and decompress files.zip archive.zip file1 file2
unzip archive.zip