Thursday, July 4, 2013

ls command explained [Learn ubuntu/Linux with me -Day 2]



Click on the images for a better enlarged view.

Just Enter these commands in your Terminal.Description gives you an idea but I'll explain in detail.

Command Equivalent Long Command Description
ls -a ls --all Lists all Files including hidden files
ls -d ls --directory Ex: ls -ld /etc Try the above command and search on google.
ls -r ls --reverse Displays results in reverse order.
ls -S no long command Sort results by file size
ls -t no long command Sort by Modification time.
ls -l no long command. Displays results in long format

I'm in my home directory,check out those images.


How to hide files in ubuntu?
Some times you need to hide some files.In windows it's simple.How do you do it in ubuntu?
Rename the file /directory to .ajay or <dot>dirname[dot followed by a name].
it's as simple as that.File is gone.

How to view Hidden files in ubuntu?
Two ways
1.ctrl+h
2.Go to terminal ==>ls -a ==> displays hidden files.

Sort the files based on size and time of Modification

ls -S ==>Sort files based on Size[Capital or big S]

ls -t ===>Sort files based on time of Modification.


ls-l Explained:

ls -l ==> To show long listing information about the file/directory.
You get many things in the output.Each term is explained.You'll find similarity but not the exact thing.
1.drwxr-xr-x or -rw-rw-r-- 
d will be there for directories.
rwxr ==> these are permissions [read /write] .You don't need much but just remember.I'll cover this in detail.
2.Next you see a number ==>Number of hard links.

What the heck is hard link??Is there something called soft links?
Yes,yes there are hard links and soft links.I'll explain in detail in my next post.

3.cam ==> The user name of the file's owner. ***this will be your username.
4.cam ==> The name of the group which owns the file. *** this will be mostly username else it will be root.
5.4096 ==> Size of the file in bytes.
6.Jul 5 09:58 ==> Date and time of the file's last modification.
7.Desktop ==> Name of the file/directory.

*** Everthing will be different for you but the pattern remains mostly same.If you've any doubts let me know.

ls --help:

Last but not least ls --help ,there are many commands you can find them along with description .

Learn python for fun.The popular blog with questions and answers to the python.Solutions to facebookhackercup,codejam,codechef.The fun way to learn python with me.Building some cool apps.

No comments:

Post a Comment