Listing Files and D...
 
Notifications
Clear all

Listing Files and Directories in Linux

1 Posts
1 Users
0 Reactions
36 Views
(@allseobasics)
Posts: 40
Member Admin
Topic starter
 

Hey guys, I have made this is an easy-to-follow step-by-step guide on Listing Files and Directories on Linux,

When you first log in to your main Linux command SSH line, your current working directory will be your home directory.

Your home directory will have a cut of your username in it, this is to keep your directory private and unique to yourself.

The command to check your current working directory is

# ls

Sometimes you will not see home dir, you might install a plugin and be in a different location, for example in the installation dir. (installed Virtualmin and our dir folder was set inside the installation dir instead of home)

As you can see from the image below;

Listing Files and Directories in Linux

So what you will need to do is move to the main root of your LINUX directory, to do this you will need to run the "# cd /" command and then run the "# ls" command again to view your home directory of your Linux.

so first run

# cd /

then run

# ls

This will then take you to the main home dir of your Linux folder. As you can see below in the image example.

home dir root of linux folder

So remember to go to your main home dir you need to run # cd/  followed by # ls

View hidden files in the dir of your Linux

To view  hidden files in the home dir of your Linux folder you will need to run #ls -a

# ls -a

When you use this command, you will see the same home DIR + any extra hidden files that may be in your current set directory.

See the image below for an example/reference, see the image shown below;

View hidden files in your dir of your Linux

There are many other behaviour commands, which simply can be added at the end of # ls, for example, # ls --color or # ls -d  or  # ls -i  there are many more check the list below.

option description
ls -a list all files including hidden files starting with '.'
ls --color colored list [=always/never/auto]
ls -d list directories - with ' */'
ls -F add one char of */=>@| to entries
ls -i list file's inode index number
ls -l list with the long format - show permissions
ls -la list long format including hidden files
ls -lh list long format with readable file size
ls -ls list with long format with file size
ls -r list in reverse order
ls -R list recursively directory tree
ls -s list file size
ls -S sort by file size
ls -t sort by time & date
ls -X sort by extension name

I hope you guys enjoy this quick Linux Tutorial, if you have any questions, please leave them below. 

Thanks.

 
Posted : 20/04/2025 5:12 pm
Share: