Examining the Linux / FreeBSD / UNIX filesystem with ls command
Q. I’m new to Linux and how do I examine filesystem and identify regular files or directories?
A. Both Linux and UNIX comes with ls command for examining the filesystem. You can use ls command to look at the filesystem. ls command can display:
=> Character devices
=> Regular files
=> Sym links (symbolic links)
=> Directories
=> Pipes
=> Sockets
=> Block devices
ls command examples
Display /etc directory files, enter:
$ ls /etc
When invoked without any arguments, ls lists the files in the current working directory:
$ ls
Use -l (long option) to lists filenames, sizes, permissions, type and all other information:
$ ls /etc/passwd
Output:
-rw-r--r-- 1 root root 2453 Jul 17 16:25 /etc/passwd
See Linux / UNIX file permissions for more information
Directory
A directory is marked with a d as the first letter of the permissions field:
ls -ld /etc
Output:
drwxr-xr-x 88 root root 12288 Aug 5 23:46 /etc
Symbolic link
A symbolic link is marked with an l (lower case L) as the first letter of the permissions string:
ls -l /bin/nisdomainname
Output:
lrwxrwxrwx 1 root root 8 Jul 10 08:50 /bin/nisdomainname -> hostname
Similarly,
- A named pipe is marked with a p as the first letter of the permissions string.
- A socket is marked with a s as the first letter of the permissions string.
- A character device is marked with a c as the first letter of the permissions strings. (ls -l /dev/console)
- A block device is marked with a b (ls -l /dev/sdb1).
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Linux / UNIX: Display file inode (index number)
- How do I find file fragmentation for specific file under Linux?
- How to: Find the inode size of an ext2 / ext3 filesystem
- Make an exact duplicate of a NTFS filesystem partition under Linux
- How do I find out more information about ext3 or ext2 file system?
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: character_device, directory_files, filesystem, Linux, ls_command, named_pipe, sockets, symbolic_link, UNIX, unix_file_permissions ~ Last updated on: August 6, 2007



Recent Comments
Today ~ 17 Comments
Today ~ 2 Comments
Today ~ 37 Comments
Today ~ 46 Comments
Yesterday ~ 2 Comments