List of Common Ubuntu Commands
- File and Directory Management
- System Information
- Package Management
- User Management
- Networking
- Disk Management
- Search and Find
- Miscellaneous
File and Directory Management
ls- List directory contentsls -a- List all files, including hidden filesls -lh- List files with human-readable sizesls -R- List files in directories and subdirectoriescd [directory]- Change the current directorycd ..- Move up one directorycd -- Switch to the previous directorycd ~- Change to the home directorypwd- Print the current working directorymkdir [directory]- Create a new directorymkdir -p [path/to/directory]- Create parent directories as neededrmdir [directory]- Remove an empty directoryrm [file]- Remove a filerm -r [directory]- Remove a directory and its contents recursivelyrm -f [file]- Force remove a file without confirmationcp [source] [destination]- Copy files and directoriescp -r [source] [destination]- Copy directories recursivelymv [source] [destination]- Move or rename files and directoriestouch [file]- Create an empty file or update the timestamp of a filecat [file]- Concatenate and display file contenthead [file]- Display the first 10 lines of a filetail [file]- Display the last 10 lines of a filetail -f [file]- Follow the end of a file in real-timefind [path] -name [filename]- Search for files by namefind [path] -type f -name '*.txt'- Find all text filesfile [filename]- Determine the file typeln -s [target] [link]- Create a symbolic linkdu -sh [directory]- Display disk usage of a directory in human-readable formatstat [file]- Display file or file system statustree- Display a directory structure in a tree format (requires installation)xargs- Build and execute command lines from standard input
System Information
uname -a- Display system informationtop- Display active processeshtop- Interactive process viewer (requires installation)df -h- Show disk space usagefree -h- Show memory usageuptime- Show how long the system has been runninglscpu- Display CPU architecture informationlsblk- List block devicesdmesg- Show kernel ring buffer messagesps aux- Display all running processeswhoami- Show the current userlast- Show last logged in userscat /proc/cpuinfo- Display CPU informationcat /proc/meminfo- Display memory informationvmstat- Report information about processes, memory, paging, block I/O, traps, and CPU activitylsof- List open files and the processes that opened themuptime- Show system load averages and uptimehostname- Display the system's hostname
Package Management
sudo apt update- Update package listssudo apt upgrade- Upgrade installed packagessudo apt dist-upgrade- Upgrade packages, handling dependenciessudo apt install [package]- Install a packagesudo apt remove [package]- Remove a packageapt search [keyword]- Search for a packagesudo apt autoremove- Remove unnecessary packagesapt list --installed- List all installed packagesapt show [package]- Display information about a packageapt-cache policy [package]- Show package version informationdpkg -l- List all installed packages using dpkgsudo apt purge [package]- Remove a package and its configuration filessudo apt-get clean- Clear local repository of retrieved package filessudo dpkg -i [package.deb]- Install a .deb packagesudo apt-mark hold [package]- Prevent a package from being upgradedapt-file search [filename]- Search for a file in available packages (requires installation)sudo apt edit-sources- Edit the sources list for package management
User Management
adduser [username]- Add a new userdeluser [username]- Delete a userpasswd [username]- Change a user's passwordgroups [username]- List groups a user belongs towho- Show who is logged inlast- Show last logged in usersusermod -aG [group] [username]- Add a user to a groupsudo su - [username]- Switch to another userfinger [username]- Show information about a userchage -l [username]- Show password aging informationsudo visudo- Edit the sudoers fileuserdel -r [username]- Delete a user and their home directoryid [username]- Show user ID and group ID informationnewgrp [group]- Log in to a new groupgroups- List groups for the current usersudo usermod -d [new_home] [username]- Change a user’s home directory
Networking
ifconfig- Display network interfaces (deprecated; useip addr)ip addr- Show IP address and network detailsping [host]- Check connectivity to a hostcurl [URL]- Transfer data from or to a serverwget [URL]- Download files from the webnetstat -tuln- Display listening portstraceroute [host]- Trace the route to a network hostnslookup [domain]- Query DNS for a domaindig [domain]- Perform DNS lookup (requires installation)whois [domain]- Retrieve domain registration informationssh [user]@[host]- Securely connect to a remote serverscp [file] [user]@[host]:[path]- Securely copy files to a remote serverftp [host]- Connect to an FTP servertelnet [host] [port]- Connect to a host via Telnet (if installed)route -n- Display the routing tableip link show- Show all network interfacesnmap [host]- Network exploration tool and security/port scanner (requires installation)
Disk Management
mount- List mounted filesystemsumount [device]- Unmount a filesystemfdisk -l- List disk partitionsdf -i- Show inode usagedu -h [directory]- Show directory size in human-readable formatlsblk- List block devices with mount pointsbadblocks [device]- Check for bad sectors on a diskfsck [device]- Check and repair a filesystemmkfs.ext4 [device]- Create an ext4 filesystem on a deviceresize2fs [device]- Resize an ext2/ext3/ext4 filesystemdd if=[source] of=[destination]- Copy and convert files (use with caution)parted [device]- Manage disk partitions interactivelymount -o loop [file] [mountpoint]- Mount an image filepvcreate [device]- Initialize a physical volume for LVMvgcreate [volume-group] [device]- Create a volume group in LVM
Search and Find
find [path] -name [filename]- Search for files by namegrep [pattern] [file]- Search for a pattern in a filelocate [filename]- Find files by name quicklywhich [command]- Show the full path of a commandwhereis [command]- Locate the binary, source, and manual page fileshistory- Show command historyecho [text]- Print text to the terminalsed 's/[old]/[new]/g' [file]- Replace text in a fileawk '{print $1}' [file]- Print the first column of a filegrep -r [pattern] [directory]- Recursively search for a pattern in a directoryfind [path] -type f -exec [command] {} \;- Execute a command on found filesxargs- Build and execute command lines from standard inputfuzzyfind [pattern]- Fuzzy search for files (requires installation)
Miscellaneous
clear- Clear the terminal screenman [command]- Display the manual for a commandalias [name]='[command]'- Create an alias for a commandunalias [name]- Remove an aliasexit- Exit the terminal sessionchmod [permissions] [file]- Change file permissionschown [user]:[group] [file]- Change file owner and grouptar -cvf [archive.tar] [directory]- Create a tar archivetar -xvf [archive.tar]- Extract a tar archivezip [archive.zip] [file]- Create a zip archiveunzip [archive.zip]- Extract a zip archivedate- Display the current date and timecal- Display a calendarexport [variable]=[value]- Set an environment variableenv- Display environment variablesecho $PATH- Display the current PATH variablecrontab -e- Edit the cron jobs for the current user