UNIX ls command is something you will need every day if you decide to move to or work on UNIX systems. UNIX ls command is used for listing files and directories on all operating systems similar to UNIX.
Depending on the directory where you are, you will get a list of files and directories, in order to check your parent dir, use UNIX pwd command.
UNIX ls command has many options, for example, if you type just ls, you will get a simple report.
If you type ls -1 (number one), you have a report format "line by line". The command ls-A produce report without the "." and "..", while the command ls -a produce report with "."
You need the directories? - You will use ls-F and at the end of each directory there will be slash ("/"), asterisk ("*") for an executable file ("@") sign to the symbolic link (or "=") for the socket.
UNIX ls command with the -g, gives a detailed report on current directory without the information about the owner:
#ls -g
total 47376
-rw-r--r-- 1 wheel 578 Aug 16 2010 .cshrc
-rw-r--r-- 1 wheel 411 Aug 16 2010 .profile
drwxr-xr-x 2 wheel 512 Aug 16 2010 altroot
drwxr-xr-x 2 wheel 1024 Aug 16 2010 bin
-rw-r--r-- 1 wheel 47320 Sep 7 2011 boot
-rw-r--r-- 1 wheel 8854601 Sep 7 2011 bsd
-rw-r--r-- 1 wheel 8878433 Sep 7 2011 bsd.mp
-rw-r--r-- 1 wheel 6327987 Sep 7 2011 bsd.rd
drwxr-xr-x 3 wheel 23552 Dec 21 05:15 dev
drwxr-xr-x 33 wheel 2560 Dec 21 05:21 etc
drwxr-xr-x 14 wheel 22016 Dec 21 06:34 home
drwxr-xr-x 6 wheel 512 Sep 26 2011 mnt
drwx------ 20 wheel 1536 Dec 21 05:16 root
drwxr-xr-x 2 wheel 1536 Aug 16 2010 sbin
drwxr-xr-x 2 wheel 512 Aug 16 2010 stand
lrwxr-xr-x 1 wheel 11 Sep 7 2011 sys -> usr/src/sys
drwxrwxrwt 5 wheel 512 Dec 21 06:32 tmp
drwxr-xr-x 17 wheel 512 Aug 8 2010 usr
drwxr-xr-x 25 wheel 512 Sep 14 2011 var
Most useful combination? For shure that is ls -l. This combination is similar to ls -g, but you will get report with owner info:
#ls -l
total 47376
-rw-r--r-- 1 root wheel 578 Aug 16 2010 .cshrc
-rw-r--r-- 1 root wheel 411 Aug 16 2010 .profile
drwxr-xr-x 2 root wheel 512 Aug 16 2010 altroot
drwxr-xr-x 2 root wheel 1024 Aug 16 2010 bin
-rw-r--r-- 1 root wheel 47320 Sep 7 2011 boot
-rw-r--r-- 1 root wheel 8854601 Sep 7 2011 bsd
-rw-r--r-- 1 root wheel 8878433 Sep 7 2011 bsd.mp
-rw-r--r-- 1 root wheel 6327987 Sep 7 2011 bsd.rd
drwxr-xr-x 3 root wheel 23552 Dec 21 05:15 dev
drwxr-xr-x 33 root wheel 2560 Dec 21 05:21 etc
drwxr-xr-x 14 root wheel 22016 Dec 21 06:34 home
drwxr-xr-x 6 root wheel 512 Sep 26 2011 mnt
drwx------ 20 root wheel 1536 Dec 21 05:16 root
drwxr-xr-x 2 root wheel 1536 Aug 16 2010 sbin
drwxr-xr-x 2 root wheel 512 Aug 16 2010 stand
lrwxr-xr-x 1 root wheel 11 Sep 7 2011 sys -> usr/src/sys
drwxrwxrwt 5 root wheel 512 Dec 21 06:32 tmp
drwxr-xr-x 17 root wheel 512 Aug 8 2010 usr
drwxr-xr-x 25 root wheel 512 Sep 14 2011 var
If you need info on last change you will use ls - lt:
#ls -lt
total 47376
drwxr-xr-x 14 root wheel 22016 Dec 21 06:34 home
drwxrwxrwt 5 root wheel 512 Dec 21 06:32 tmp
drwxr-xr-x 33 root wheel 2560 Dec 21 05:21 etc
drwx------ 20 root wheel 1536 Dec 21 05:16 root
drwxr-xr-x 3 root wheel 23552 Dec 21 05:15 dev
drwxr-xr-x 6 root wheel 512 Sep 26 2011 mnt
drwxr-xr-x 25 root wheel 512 Sep 14 2011 var
-rw-r--r-- 1 root wheel 47320 Sep 7 2011 boot
lrwxr-xr-x 1 root wheel 11 Sep 7 2011 sys -> usr/src/sys
-rw-r--r-- 1 root wheel 8878433 Sep 7 2011 bsd.mp
-rw-r--r-- 1 root wheel 6327987 Sep 7 2011 bsd.rd
-rw-r--r-- 1 root wheel 8854601 Sep 7 2011 bsd
drwxr-xr-x 2 root wheel 1536 Aug 16 2010 sbin
drwxr-xr-x 2 root wheel 1024 Aug 16 2010 bin
-rw-r--r-- 1 root wheel 578 Aug 16 2010 .cshrc
-rw-r--r-- 1 root wheel 411 Aug 16 2010 .profile
drwxr-xr-x 2 root wheel 512 Aug 16 2010 altroot
drwxr-xr-x 2 root wheel 512 Aug 16 2010 stand
drwxr-xr-x 17 root wheel 512 Aug 8 2010 usr
Last access time is available with ls -lu:
#ls -lu
total 47376
-rw-r--r-- 1 root wheel 578 Jan 29 2012 .cshrc
-rw-r--r-- 1 root wheel 411 Jan 29 2012 .profile
drwxr-xr-x 2 root wheel 512 Dec 21 07:09 altroot
drwxr-xr-x 2 root wheel 1024 Dec 21 07:20 bin
-rw-r--r-- 1 root wheel 47320 Jan 29 2012 boot
-rw-r--r-- 1 root wheel 8854601 Jan 29 2012 bsd
-rw-r--r-- 1 root wheel 8878433 Jan 29 2012 bsd.mp
-rw-r--r-- 1 root wheel 6327987 Jan 29 2012 bsd.rd
drwxr-xr-x 3 root wheel 23552 Dec 21 07:17 dev
drwxr-xr-x 33 root wheel 2560 Dec 21 07:09 etc
drwxr-xr-x 14 root wheel 22016 Dec 21 07:09 home
drwxr-xr-x 6 root wheel 512 Dec 21 07:17 mnt
drwx------ 20 root wheel 1536 Dec 21 07:13 root
drwxr-xr-x 2 root wheel 1536 Dec 21 07:17 sbin
drwxr-xr-x 2 root wheel 512 Dec 21 07:10 stand
lrwxr-xr-x 1 root wheel 11 Sep 7 2011 sys -> usr/src/sys
drwxrwxrwt 5 root wheel 512 Dec 21 07:18 tmp
drwxr-xr-x 17 root wheel 512 Dec 21 07:16 usr
drwxr-xr-x 25 root wheel 512 Dec 21 07:07 var
Always check your man ls page.
No comments:
Post a Comment