- pwd (Print Working Directory):
Thepwdcommand is used to display the current working directory in the Linux terminal. When you run this command, it will print the absolute path of the directory you are currently in.
Example:
$ pwd
/home/user/documents
- ls (List):
Thelscommand is used to list the files and directories in the current working directory. By default, it displays the names of the files and directories in a simple list format.
Example:
$ ls
file1.txt file2.txt folder1 folder2
- cd (Change Directory):
Thecdcommand is used to change the current working directory. You can navigate to a different directory by specifying its path.
Example:
$ cd /home/user/documents/folder1
- mkdir (Make Directory):
Themkdircommand allows you to create new directories (folders) in the file system.
Example:
$ mkdir new_folder
- df (Disk Free):
Thedfcommand is used to display information about the disk space usage of the file system.
Example:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 50G 50G 50% /
- rm (Remove):
Thermcommand is used to delete files or directories. Be cautious when using this command as deleted files cannot be easily recovered.
Example:
$ rm file1.txt
- cp (Copy):
Thecpcommand is used to copy files or directories from one location to another.
Example:
$ cp file1.txt /backup
- mv (Move):
Themvcommand is used to move files or directories from one location to another. It can also be used to rename files or directories.
Example:
$ mv file1.txt /home/user/documents/folder1
- du (Disk Usage):
Theducommand is used to display disk usage information for files and directories.
Example:
$ du -h file1.txt
10K file1.txt
- ssh (Secure Shell):
Thesshcommand is used to remotely access and manage a computer over a network. It provides a secure encrypted connection.
Example:
$ ssh [email protected]
- ifconfig (Interface Configuration):
Theifconfigcommand is used to display network interface configuration information, such as IP addresses, netmask, and network-related statistics.
Example:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0A:CD:22:F3:11
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
- cat (Concatenate):
Thecatcommand is used to display the content of a file in the terminal. It can also be used to concatenate and display multiple files’ contents.
Example:
$ cat file1.txt
This is the content of file1.txt
- grep (Global Regular Expression Print):
Thegrepcommand is used to search for a specific pattern or text in files. It can be used with regular expressions for powerful searches.
Example:
$ grep "error" log.txt
- nano/vi (Text Editors):
Thenanoandvicommands are text editors that allow you to create and modify text files directly from the terminal.
Example (using nano):
$ nano newfile.txt
- man (Manual Pages):
Themancommand is used to display the manual pages for various commands. It provides detailed information about how to use the specified command.
Example:
$ man ls
- ping:
Thepingcommand is used to test the reachability of a host (usually through its IP address) on a network and measure the round-trip time for packets.
Example:
$ ping google.com
- wget:
Thewgetcommand is used to download files from the internet via HTTP, HTTPS, or FTP protocols.
Example:
$ wget https://example.com/file.zip
- chmod (Change Mode):
Thechmodcommand is used to change the permissions of files and directories in Linux.
Example:
$ chmod 755 script.sh
- chown (Change Owner):
Thechowncommand is used to change the ownership of files and directories to a specific user or group.
Example:
$ chown user:group file.txt
- ps (Process Status):
Thepscommand is used to display information about running processes on the system.
Example:
$ ps -ef
- kill:
Thekillcommand is used to terminate processes by sending them signals. The most common signal is SIGKILL (signal 9) to forcefully terminate a process.
Example:
$ kill PID
- tar (Tape Archive):
Thetarcommand is used to create, view, or extract tar archives, which can contain multiple files and directories.
Example (creating a tar archive):
$ tar -cvf archive.tar file1.txt file2.txt
These are some of the most common Linux commands along with their brief descriptions and examples. Linux offers a wide range of commands and options to accomplish various tasks efficiently from the command line.