Summer training at Goeduhub Technologies-Jaipur
Register for Free Certified Workshop on RTU Python Lab (VI SEM):: 01-03-2020 ||  Career options for aspiring CS/ITECEEE or EIC or EEE Engineers
0 like 0 dislike
5 views
in Tutorial & Interview questions by Summer Trainee (7k points)

1 Answer

0 like 0 dislike
by Summer Trainee (7k points)
 
Best answer

Options for ls command

Full list of options:
ls -a list all files including hidden file starting with '.'
ls --color colored list [=always/never/auto]
ls -d list directories - with ' */'
ls -F add one char of */=>@| to enteries
ls -i list file's inode index number
ls -l list with 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

ls command with most used options

ls shows files and directories in present working directory. (if no arguments are passed.) (It doesn't show hidden files which starts with . by default.)
user@ubuntu14:/usr$ ls
bin games include lib lib32 local sbin share src
To see all files (hidden files/folders also). Use ls -a OR ls -all
user@ubuntu14:/usr$ ls -a
. .. bin games include lib lib32 local sbin share src
To differentiate between files and folders and symbolic links and other, use ls -F OR ls --classify
user@ubuntu14:~$ ls -F
bash_profile_course chat_apps/ Desktop/ Downloads/ foxitsoftware/
Public/ test/ bin/ ClionProjects/ Documents/ IDE/ Music/
Pictures/ Templates/ Videos/

Here, ending characters are used to distinguish files and folders.

“/” suggest directory.

“*”suggest executables.

“@” suggest symbolic links.

To get more details about the files and directories, use ls -l

user@ubuntu14:~/example$ ls -l

total 6464

-rw-r--r-- 1 dave dave 41 Dec 24 12:19 Z.txt

drwxr-xr-x 2 user group 4096 Dec 24 12:00 a_directory

-rw-r--r-- 1 user group 6 Dec 24 12:01 a_file

lrwxrwxrwx 1 user group 6 Dec 24 12:04 a_link -> a_file

-rw-r--r-- 1 user group 6 Dec 24 12:03 a_newer_file

-rw-r----- 1 user group 6586816 Dec 24 12:07 big.zip 

In this example, the total size of the contents is 6460KB.

Then there is an entry for each file/directory in alphabetical order with upper case before lower case.

The first character is the type (e.g. d - directory, l - link).

The next 9 characters show the permissions for the user, group and other.

This is followed by the number of hard links, then the owner's name and group.

The next field is the size in bytes. This can be displayed in a human friendly form by adding the -h option e.g. 6586816 is displayed as 6.3M

There then follows a timestamp (usually the modification time).

The final field is the name. Note: links also show the target of the link. 

Related questions

0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...