Below is a comprehensive list of commonly used basic commands in the Linux terminal. These commands are essential for managing the system, interacting with files, and performing various tasks through the command-line interface.
pwd
: Display the current working directory.ls
: List files and directories in the current directory.ls -l
: Display file/directory information in long format.ls -a
: Display all files/directories, including hidden ones.
cd
: Change directory.cd [directory_name]
: Move to the specified directory.cd ..
: Move to the parent directory.cd ~
: Move to the user's home directory.
mkdir
: Create a new directory.mkdir [directory_name]
: Create a directory with a specific name.
touch
: Create an empty file. -touch [file_name]
: Create a file with a specific name.cp
: Copy files/directories.cp [source] [destination]
: Copy source to destination.
mv
: Move or rename files/directories.mv [source] [destination]
: Move source to destination.mv [old_name] [new_name]
: Rename a file/directory.
rm
: Delete files/directories.rm [file_name]
: Delete a file with a specific name.rm -r [directory_name]
: Delete a directory and its contents recursively.
cat
: Display the contents of a file in the terminal.cat [file_name]
: Display the contents of a specific file.
nano
orvim
: Edit text files in the terminal.echo
: Display text in the terminal or save it to a file.echo [text]
: Display text in the terminal.echo [text] > [file_name]
: Save text to a file (overwrite content).echo [text] >> [file_name]
: Append text to a file (without overwriting).
uname
: Display information about the system.uname -a
: Display detailed system information.
top
: Display a list of running processes.free
: Display memory usage.df
: Display disk space usage information.
sudo
: Execute commands as a superuser (root).useradd
: Add a new user.passwd
: Change a user's password.chmod
: Change file/directory permissions.chown
: Change file/directory ownership.
ping
: Send ICMP echo packets to a network address.ping [ip_address]
: Send ping packets to an IP address.
ifconfig
orip
: Display network interface information.ssh
: Access a remote machine using Secure Shell (SSH).ssh [username]@[ip_address]
: Connect to a remote machine.
APT is the default package management tool for Ubuntu and Debian systems. It simplifies software management by handling package dependencies and updates.
To ensure you have the latest package information, update the package lists:
sudo apt update
To install a package, use the apt install
command followed by the package name:
sudo apt install [package_name]
To remove a package (while keeping configuration files):
sudo apt remove [package_name]
To remove a package and its configuration files:
sudo apt purge [package_name]
To upgrade all installed packages:
sudo apt upgrade
To perform a full system upgrade (including kernel upgrades):
sudo apt full-upgrade
To search for packages by name:
apt search [search_term]
To display detailed information about a package:
apt show [package_name]
The dpkg
command is a lower-level package manager that apt
relies on. It can be used to directly manipulate .deb
packages.
To install a .deb
package:
sudo dpkg -i [package_file.deb]
Synaptic provides a graphical user interface for package management. Install it using:
sudo apt install synaptic
Aptitude is another command-line package manager that provides more advanced package management capabilities:
To install Aptitude:
sudo apt install aptitude
To search for packages:
aptitude search [search_term]
To install a package:
sudo aptitude install [package_name]
These commands should cover the basics of package management in Ubuntu and Debian-based systems. Remember to use sudo
to execute commands as a superuser when required.
Pacman is a powerful package manager designed for Arch Linux and its derivatives.
To ensure you have the latest package information, update the package database:
sudo pacman -Sy
To install a package, use the pacman -S
command followed by the package name:
sudo pacman -S [package_name]
To remove a package (while keeping configuration files):
sudo pacman -R [package_name]
To remove a package and its configuration files:
sudo pacman -Rs [package_name]
To remove a package and its unused dependencies:
sudo pacman -Rns [package_name]
To upgrade all installed packages:
sudo pacman -Syu
To search for packages by name or description:
pacman -Ss [search_term]
To display detailed information about a package:
pacman -Si [package_name]
While not recommended due to security concerns, Yaourt was a popular AUR helper. If you still use it, the commands are:
To install a package from the AUR:
yaourt -S [package_name]
Yay is a popular and community-driven AUR helper:
To install a package from the AUR using yay:
yay -S [package_name]
The AUR contains user-contributed packages not found in official repositories.
To build and install a package from the AUR using makepkg
:
- Download the AUR package source.
- Extract the source and navigate to the package directory.
- Build the package:
makepkg -si
Pacman hooks are scripts that run at specific points during package installation and removal. Hooks can be found in /usr/share/libalpm/hooks/
.
Regularly update your system to ensure security and stability:
sudo pacman -Syu
These commands should help you manage packages efficiently on your Arch Linux system. Remember to use sudo
to execute commands as a superuser when required.
Red Hat Enterprise Linux (RHEL), CentOS, and Fedora use the DNF package manager for handling software installation, updates, and removal.
DNF (Dandified Yum) is a package manager designed for RHEL, CentOS, Fedora, and related distributions.
To ensure you have the latest package information, update the package database:
sudo dnf update
To install a package, use the dnf install
command followed by the package name:
sudo dnf install [package_name]
To remove a package:
sudo dnf remove [package_name]
To upgrade all installed packages:
sudo dnf upgrade
To search for packages by name:
dnf search [search_term]
To display detailed information about a package:
dnf info [package_name]
DNF can also manage package groups. To install a package group:
sudo dnf groupinstall [group_name]
To list enabled repositories:
dnf repolist
To clean package cache and free up space:
sudo dnf clean all
RPM Fusion is a third-party repository that provides additional packages for Fedora-based distributions. To enable it:
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
DNF has several plugins that provide additional functionalities. Some commonly used ones include:
dnf-automatic
: Automatically updates the system.dnf-plugin-system-upgrade
: Supports system upgrades.
Regularly update your system to ensure security and stability:
sudo dnf upgrade
These commands should help you manage packages efficiently on your RHEL, CentOS, or Fedora system. Remember to use sudo
to execute commands as a superuser when required.
openSUSE uses the Zypper package manager for handling software installation, updates, and removal.
Zypper is a powerful package manager designed for openSUSE distributions.
To ensure you have the latest package information, update the package database:
sudo zypper refresh
To install a package, use the zypper install
command followed by the package name:
sudo zypper install [package_name]
To remove a package:
sudo zypper remove [package_name]
To upgrade all installed packages:
sudo zypper update
To search for packages by name:
zypper search [search_term]
To display detailed information about a package:
zypper info [package_name]
To list enabled repositories:
zypper repos
To add a repository:
sudo zypper addrepo [repository_url] [alias]
To clean the package cache and free up space:
sudo zypper clean
YaST is a comprehensive configuration and management tool for openSUSE. It provides a graphical interface for package management and other system tasks.
Regularly update your system to ensure security and stability:
sudo zypper update
These commands should help you manage packages efficiently on your openSUSE system. Remember to use sudo
to execute commands as a superuser when required.
Gentoo Linux uses a unique package management system called Portage for handling software installation, updates, and removal.
Portage is a source-based package management system for Gentoo. It compiles packages from source code on your system, allowing for customization and optimization.
To ensure you have the latest package information, update the Portage tree:
sudo emerge --sync
To install a package, use the emerge
command followed by the package name:
sudo emerge [package_name]
To remove a package:
sudo emerge --unmerge [package_name]
To update all installed packages:
sudo emerge --update --deep --with-bdeps=y --newuse @world
To search for packages by name:
eix [search_term]
To display detailed information about a package:
equery show [package_name]
Use flags are options that allow you to customize the features and dependencies of packages. You can manage local use flags by editing /etc/portage/package.use
and /etc/portage/package.mask
.
To clean package build files:
sudo eclean-dist
Regularly update your system to ensure security and stability:
sudo emerge --sync sudo emerge --update --deep --with-bdeps=y --newuse @world
These commands should help you manage packages efficiently on your Gentoo system. Remember to use sudo
to execute commands as a superuser when required.
If there are errors in this repository, please open an issue or you can contribute to improving this repository.