Basic List & Directory Commands in Linux
Shaikh Zahid
DevOps Engineer| Python| Linux| Git & GitHub| Frontend Web Development| HTML| CSS| Java Script| SQL| JAVA| Digital Marketing| Web Design(WordPress).
If you're just starting with Linux, you must know how to work with files and directories. Here’s a quick guide on some of the most commonly used commands to list and manage directories.
1. Listing Commands
Example:?
-Command: ls
-Output: file1.txt? file2.txt? directory1
Example:
-Command: ls -l?
-Output: drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 15 16:27 devops1
-rw-rw-r-- 1 ubuntu ubuntu 0 Oct 15 16:28 first.txt
Example:
-Command: ls -a
-Output: . .. .bash_history .bash_logout .bashrc .cache .lesshst .profile .ssh .sudo_as_admin_successful .viminfo devops
Example:
-Command: ls -Ih
-Output: total 4.0K
drwxrwxr-x 3 ubuntu ubuntu 4.0K Oct 15 16:28 devops
Example:
-Command: ls -R
-Output: .:
devops
./devops:
devops1 first.txt
./devops/devops1:
second.txt
2. Directories Commands
领英推荐
Example:
Command: pwd
Output: /home/ubuntu/devops
Example:
Command: cd devops1
Output: ubuntu@ip-111-31-31-515:~/devops/devops1$
Example:
Command: cd ..
Output: ubuntu@ip-111-31-31-515:~/devops$
Example:
Command: cd ~
Output: ubuntu@ip-111-31-31-515:~$
Example:
Command: -mkdir new_folder
-ls
Output: devops1 first.txt new_folder
Example:
Command: rmdir new_folder
-ls
Output: devops1 first.txt
Example:
Command: rm -r new_folder
ubuntu@ip-111-31-31-515:~/devops/new_folder$ ls
third.txt
Output: ubuntu@ip-111-31-31-515:~/devops$ ls
devops1 first.txt
These basic list and directory commands are just a starting point for managing files and directories in Linux. They help you navigate and organize your system more efficiently. By exploring more options and practicing, you’ll gradually become proficient in using the Linux command line.