Show List

Basic Linux commands and file system navigation

  • cd - change directory: This command is used to change the current working directory to another directory.
bash
Copy code
cd /home/user1/

This will change the current directory to "/home/user1/"

  • ls - list directory contents: This command is used to list the files and directories in the current directory.
bash
Copy code
ls

This will display a list of files and directories in the current directory.

  • mkdir - make directory: This command is used to create a new directory.
bash
Copy code
mkdir newdirectory

This will create a new directory named "newdirectory" in the current directory.

  • touch - create an empty file: This command is used to create a new empty file.
bash
Copy code
touch newfile.txt

This will create a new file named "newfile.txt" in the current directory.

  • cp - copy a file or directory: This command is used to copy a file or directory from one location to another.
bash
Copy code
cp file1.txt /home/user1/

This will copy the file "file1.txt" to the directory "/home/user1/"

  • mv - move or rename a file or directory: This command is used to move a file or directory from one location to another, or to rename a file or directory.
bash
Copy code
mv file1.txt /home/user1/

This will move the file "file1.txt" to the directory "/home/user1/"

bash
Copy code
mv file1.txt file2.txt

This will rename the file "file1.txt" to "file2.txt"

  • rm - remove a file or directory: This command is used to delete a file or directory.
bash
Copy code
rm file1.txt

This will delete the file "file1.txt"

bash
Copy code
rm -r directory1

This will delete the directory "directory1" and all its contents.

  • pwd - print working directory: This command is used to display the current working directory.
bash
Copy code
pwd

This will display the current working directory.

  • cat - concatenate and display files: This command is used to display the contents of one or more files.
bash
Copy code
cat file1.txt

This will display the contents of the file "file1.txt".

  • head - display the first lines of a file: This command is used to display the first few lines of a file.
bash
Copy code
head file1.txt

This will display the first few lines of the file "file1.txt".

  • tail - display the last lines of a file: This command is used to display the last few lines of a file.
bash
Copy code
tail file1.txt

This will display the last few lines of the file "file1.txt".

  • grep - search for a pattern in a file: This command is used to search for a specific pattern or string in a file.
perl
Copy code
grep "pattern" file1.txt

This will search for the string "pattern" in the file "file1.txt".

  • find - search for files and directories: This command is used to search for files and directories in a specific directory.
bash
Copy code
find /home/user1/ -name "file1.txt"

This will search for the file "file1.txt" in the directory "/home/user1/".

  • tar - create or extract a compressed archive: This command is used to create or extract a compressed archive.
Copy code
tar -cvf archive.tar file1.txt file2.txt

This will create a compressed archive named "archive.tar" containing the files "file1.txt" and "file2.txt".

Copy code
tar -xvf archive.tar

This will extract the files from the archive "archive.tar".

  • zip - compress or extract files: This command is used to compress or extract files.
python
Copy code
zip archive.zip file1.txt file2.txt

This will create a compressed archive named "archive.zip" containing the files "file1.txt" and "file2.txt".

python
Copy code
unzip archive.zip

This will extract the files from the archive "archive.zip".

  • chmod - change file permissions: This command is used to change the permissions of a file or directory.
bash
Copy code
chmod 755 file1.txt

This will set the permissions of the file "file1.txt" to 755.

  • chown - change file ownership: This command is used to change the ownership of a file or directory.
bash
Copy code
chown user1:group1 file1.txt

This will change the ownership of the file "file1.txt" to user1 and group1.

  • ssh - remote login: This command is used to log in to a remote server.
css
Copy code
ssh user1@192.168.0.1

This will log in to the server at IP address 192.168.0.1 as user1.

  • scp - copy files between hosts: This command is used to copy files between two remote hosts.
ruby
Copy code
scp file1.txt user1@192.168.0.1:/home/user1/

This will copy the file "file1.txt" to the directory "/home/user1/" on the remote server at IP address 192.168.0.1.

  • ps - list running processes: This command is used to list the running processes on a system.
Copy code
ps -ef

This will display a list of all running processes on the system.

  • kill - terminate a process: This command is used to terminate a running process.
bash
Copy code
kill PID

This will terminate the process with the specified PID (process ID).

  • df - display free disk space: This command is used to display the amount of free disk space on a system.
bash
Copy code
df -h

This will display the amount of free disk space on the system in a human-readable format.

  • du - display disk usage: This command is used to display the disk usage of a file or directory.
bash
Copy code
du -h file1.txt

This will display the disk usage of the file "file1.txt" in a human-readable format.

  • top - display system resources: This command is used to display real-time information about system resources, such as CPU and memory usage.
css
Copy code
top

This will display real-time information about system resources in a terminal window.

  • ps aux - list running processes: This command is used to list the running processes on a system.
Copy code
ps aux

This will display a list of all running processes on the system.

  • netstat - display network connections: This command is used to display the network connections on a system.
css
Copy code
netstat -a

This will display a list of all network connections on the system.

  • ping - test network connectivity: This command is used to test network connectivity.
Copy code
ping 192.168.0.1

This will send ICMP packets to the IP address 192.168.0.1 to test network connectivity.

  • ifconfig - configure network interfaces: This command is used to configure network interfaces.
Copy code
ifconfig eth0 192.168.0.2 netmask 255.255.255.0

This will configure the network interface eth0 with the IP address 192.168.0.2 and netmask 255.255.255.0.

  • iwconfig - configure wireless network interfaces: This command is used to configure wireless network interfaces.
vbnet
Copy code
iwconfig wlan0 essid "MyWiFi" key s:password

This will configure the wireless network interface wlan0 to connect to the network "MyWiFi" with the password "password".

  • route - display or configure the network routing table: This command is used to display or configure the network routing table.
Copy code
route -n

This will display the network routing table.

  • traceroute - trace the route to a network host: This command is used to trace the route to a network host.
Copy code
traceroute google.com

This will trace the route to the network host google.com.

  • wget - download files from the internet: This command is used to download files from the internet.
javascript
Copy code
wget https://example.com/file1.txt

This will download the file "file1.txt" from the website "example.com".

  • curl - transfer data from or to a server: This command is used to transfer data from or to a server.
javascript
Copy code
curl -o file1.txt https://example.com/file1.txt

This will download the file "file1.txt" from the website "example.com" and save it as "file1.txt".

  • ssh-keygen - generate SSH keys: This command is used to generate SSH keys.
css
Copy code
ssh-keygen -t rsa -b 4096

This will generate a new RSA key pair 

  • ssh - connect to a remote server using SSH: This command is used to connect to a remote server using SSH.
sql
Copy code
ssh user@remote_host

This will establish an SSH connection to the remote host using the specified username.

  • scp - copy files between hosts using SSH: This command is used to copy files between hosts using SSH.
ruby
Copy code
scp file1.txt user@remote_host:/home/user/

This will copy the file "file1.txt" to the remote host's "/home/user/" directory using SSH.

  • rsync - synchronize files between hosts: This command is used to synchronize files between hosts.
ruby
Copy code
rsync -avz /local/path user@remote_host:/remote/path

This will synchronize the files from the local "/local/path" directory to the remote "/remote/path" directory using rsync.

  • tar - create and extract tar archives: This command is used to create and extract tar archives.
Copy code
tar -cvf archive.tar file1.txt file2.txt

This will create a new tar archive called "archive.tar" containing "file1.txt" and "file2.txt".

Copy code
tar -xvf archive.tar

This will extract the contents of the tar archive "archive.tar".

  • gzip and gunzip - compress and decompress files: These commands are used to compress and decompress files.
Copy code
gzip file1.txt

This will compress the file "file1.txt".

Copy code
gunzip file1.txt.gz

This will decompress the file "file1.txt.gz".

  • chown - change the ownership of a file or directory: This command is used to change the ownership of a file or directory.
sql
Copy code
chown user:group file1.txt

This will change the owner of the file "file1.txt" to the specified user and group.

  • chmod - change the permissions of a file or directory: This command is used to change the permissions of a file or directory.
bash
Copy code
chmod 644 file1.txt

This will change the permissions of the file "file1.txt" to read and write for the owner and read-only for everyone else.

  • find - search for files or directories: This command is used to search for files or directories.
lua
Copy code
find / -name file1.txt

This will search for the file "file1.txt" in the entire file system.

  • grep - search for a pattern in a file: This command is used to search for a pattern in a file.
perl
Copy code
grep "pattern" file1.txt

This will search for the specified pattern in the file "file1.txt".

  • sed - search and replace text in a file: This command is used to search and replace text in a file.
python
Copy code
sed -i 's/old_text/new_text/g' file1.txt

This will replace all instances of "old_text" with "new_text" in the file "file1.txt".

  • awk - manipulate and analyze text files: This command is used to manipulate and analyze text files.
swift
Copy code
awk '{print $1, $2}' file1.txt

This will print the first two columns of the file "file1.txt".

  • tail - display the last few lines of a file: This command is used to display the last few lines of a file.
bash
Copy code
tail file1.txt

This will display the last 10 lines of the file

  • head - display the first few lines of a file: This command is used to display the first few lines of a file.
bash
Copy code
head file1.txt

This will display the first 10 lines of the file "file1.txt".

  • tee - redirect output to a file and the terminal: This command is used to redirect output to a file and the terminal.
bash
Copy code
ls | tee file1.txt

This will list the files in the current directory and save the output to the file "file1.txt" and also display the output on the terminal.

  • cut - extract columns from a file: This command is used to extract columns from a file.
bash
Copy code
cut -d "," -f 1,2 file1.txt

This will extract the first two columns of the file "file1.txt" using the comma as the delimiter.

  • paste - merge lines from multiple files: This command is used to merge lines from multiple files.
bash
Copy code
paste file1.txt file2.txt

This will merge the lines from the two files "file1.txt" and "file2.txt".

  • sort - sort lines in a file: This command is used to sort lines in a file.
bash
Copy code
sort file1.txt

This will sort the lines in the file "file1.txt" in ascending order.

  • uniq - remove duplicate lines from a file: This command is used to remove duplicate lines from a file.
bash
Copy code
uniq file1.txt

This will remove any duplicate lines in the file "file1.txt".

  • wc - count lines, words, and characters in a file: This command is used to count the number of lines, words, and characters in a file.
bash
Copy code
wc file1.txt

This will display the number of lines, words, and characters in the file "file1.txt".

  • df - display disk space usage: This command is used to display the disk space usage.
bash
Copy code
df -h

This will display the disk space usage in a human-readable format.

  • du - display the size of a file or directory: This command is used to display the size of a file or directory.
bash
Copy code
du -sh /home/user/

This will display the size of the "/home/user/" directory in a human-readable format.

  • top - display system processes and resource usage: This command is used to display system processes and resource usage.
css
Copy code
top

This will display the system processes and their resource usage in real-time.

  • ps - display running processes: This command is used to display the running processes.
Copy code
ps

This will display the currently running processes.

  • kill - send a signal to a process: This command is used to send a signal to a process.
bash
Copy code
kill PID

This will send a signal to the process with the specified process ID (PID).

  • ping - test network connectivity: This command is used to test network connectivity.
Copy code
ping google.com

This will test the network connectivity to "google.com".

  • traceroute - trace the network path to a host: This command is used to trace the network path to a host.
Copy code
traceroute google.com

This will trace the network path to "google.com".

  • nslookup - query DNS information: This command is used to query DNS information.
Copy code
nslookup google.com

This will query the DNS information for "google.com".

  • dig - DNS lookup utility: This command is used to perform DNS lookups.
Copy code
dig google.com

This will perform a DNS lookup for "google.com".

  • ssh - secure shell client: This command is used to connect to a remote system using the secure shell (SSH) protocol.
sql
Copy code
ssh user@remote_host

This will connect to the remote system with the username "user" at the hostname "remote_host".

  • scp - secure copy: This command is used to copy files between systems using the secure copy (SCP) protocol.
ruby
Copy code
scp file.txt user@remote_host:/path/to/destination

This will copy the file "file.txt" to the remote system at the specified destination.

  • rsync - remote file sync: This command is used to synchronize files between systems.
ruby
Copy code
rsync -avz /path/to/source user@remote_host:/path/to/destination

This will synchronize the files from the local system to the remote system.

  • tar - archive files: This command is used to create an archive of one or more files.
Copy code
tar -cvf archive.tar file1.txt file2.txt

This will create an archive called "archive.tar" containing the files "file1.txt" and "file2.txt".

  • gzip - compress files: This command is used to compress files.
Copy code
gzip file1.txt

This will compress the file "file1.txt" and create a new file called "file1.txt.gz".

  • gunzip - uncompress files: This command is used to uncompress files.
Copy code
gunzip file1.txt.gz

This will uncompress the file "file1.txt.gz" and create a new file called "file1.txt".

  • curl - transfer data from or to a server: This command is used to transfer data from or to a server.
javascript
Copy code
curl https://example.com

This will retrieve the content of the specified URL.

  • wget - download files from the internet: This command is used to download files from the internet.
javascript
Copy code
wget https://example.com/file.txt

This will download the file "file.txt" from the specified URL.

  • history - display command history: This command is used to display the command history.
bash
Copy code
history

This will display the command history of the current session.

  • alias - create an alias for a command: This command is used to create an alias for a command.
bash
Copy code
alias ll='ls -l'

This will create an alias "ll" for the "ls -l" command.


    Leave a Comment


  • captcha text