0% found this document useful (0 votes)
14 views

Linux Command

Uploaded by

sagorsheikh545
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Linux Command

Uploaded by

sagorsheikh545
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Linux command

1. pwd
o Purpose: Displays the current directory's full path.
o Example:
pwd
Output: /home/user
2. ls
o Purpose: Lists files and directories in the current directory.
o Example:
ls
Use ls -a to include hidden files or ls -l for detailed information.
3. cd
o Purpose: Change the current working directory.
o Example:
cd /home/user/documents
Moves into the specified directory.
4. mkdir
o Purpose: Creates a new directory.
o Example:
mkdir my_folder
Creates a directory named my_folder.
5. rmdir
o Purpose: Deletes an empty directory.
o Example:
rmdir my_folder
Removes the directory my_folder.
6. rm
o Purpose: Deletes files or directories.
o Example:
rm file.txt
Deletes file.txt. Use rm -r folder_name to remove directories recursively.
7. touch
o Purpose: Creates an empty file or updates the timestamp of an existing file.
o Example:
touch newfile.txt
Creates a blank file named newfile.txt.
8. cp
o Purpose: Copies files or directories.
o Example:
cp source.txt destination.txt
Copies source.txt to destination.txt.
9. mv
o Purpose: Moves or renames files/directories.
o Example:
mv old_name.txt new_name.txt
Renames the file old_name.txt to new_name.txt.
10. cat
o Purpose: Displays the content of a file.
o Example:
cat file.txt
Prints the content of file.txt to the terminal.
11. nano
o Purpose: Opens a file in the Nano text editor.
o Example:
nano file.txt
Opens file.txt for editing.
12. echo
o Purpose: Prints text or variables to the terminal.
o Example:
echo "Hello, World!"
Displays: Hello, World!.
13. find
o Purpose: Searches for files or directories.
o Example:
find /home -name file.txt
Searches for file.txt in /home.

14. grep
o Purpose: Searches for text patterns in files.
o Example:
grep "text" file.txt
Finds and displays lines containing "text" in file.txt.
15. chmod
o Purpose: Changes file or directory permissions.
o Example:
chmod 755 script.sh
Assigns read, write, and execute permissions to the owner.
16. df
o Purpose: Displays disk space usage.
o Example:
df -h
Shows disk space in a human-readable format.
17. du
o Purpose: Displays the size of directories or files.
o Example:
du -sh /home/user
Displays the size of the /home/user directory.
18. ps
o Purpose: Lists running processes.
o Example:
ps -aux
Shows detailed information about all running processes.
19. top
o Purpose: Monitors real-time system resource usage.
o Example:
top
Displays CPU and memory usage dynamically.
20. kill
o Purpose: Terminates processes by ID.
o Example:
kill 1234
Kills the process with ID 1234.
21. tar
o Purpose: Archives files or extracts archives.
o Example:
tar -czvf archive.tar.gz file1 file2
Creates a compressed archive of file1 and file2.
22. zip
o Purpose: Compresses files into a zip archive.
o Example:
zip archive.zip file.txt
Creates a zip file archive.zip containing file.txt.
23. unzip
o Purpose: Extracts files from a zip archive.
o Example:
unzip archive.zip
Extracts the contents of archive.zip.
24. wget
o Purpose: Downloads files from the internet.
o Example:
wget https://example.com/file.txt
Downloads file.txt from the specified URL.
25. curl
o Purpose: Transfers data from or to a server.
o Example:
curl https://example.com
Fetches the contents of the URL.
26. ifconfig
o Purpose: Displays or configures network interfaces.
o Example:
ifconfig
Shows IP and network details.
27. ping
o Purpose: Tests network connectivity to a host.
o Example:
ping google.com
Sends ICMP requests to google.com.
28. netstat
o Purpose: Displays network connections and statistics.
o Example:
netstat -tuln
Lists active listening ports.
29. ssh
o Purpose: Connects to a remote machine securely.
o Example:
ssh [email protected]
Logs into the remote host.
30. man
o Purpose: Displays the manual for a command.
o Example:
man ls
Shows the manual page for the ls command.
31. alias
o Purpose: Creates shortcuts for commands.
o Example:
alias ll='ls -la'
Sets ll as a shortcut for ls -la.
32. history
o Purpose: Displays previously executed commands.
o Example:
history
Shows a list of past commands.

You might also like