CS 497C – Introduction to UNIX Lecture 14: - File Attributes Chin-Chih Chang chang@cs.twsu.edu ls: Listing Files * When you use the ls command, you will see a list of filenames arranged in ASCII collating sequence. * You can use ls with the filename to know whether a particular file is available. * Use the –x option to produce a multicolumn output. * Use the –F option to identify directories and executables. ls: Listing Files * The * indicates the file is an executable code. * The / indicates the file is a directory. * The –a (all) option lists all hidden files. * Hidden files are those beginning with a dot. * Generally, these dot files are startup files for their corresponding commands. $ ls –Fax ./ ../ .Xauthority .cshrc* .cshrc.dec* .cshrc.linux* .cshrc.next* .cshrc.solaris* .cshrc.sun* .login* * . represents the current directory. ls: Listing Files * .. represents the parent directory. * When ls is used with the directory, it shows the contents of the directory. * The –R (recursive) option lists all files and subdirectories in a directory. * The –l (long) option of ls reveals most attributes of a file – like its permissions, size, and ownership details. ls –l: List File Attributes kirk> ls -l total 7 drwxr-xr-x 2 cs497c grader 1024 Sep 25 11:30 bin -rw------- 1 cs497c grader 306 Sep 26 11:55 chap3 -rw------- 1 cs497c grader 306 Sep 26 11:55 chap5 drwx------ 2 cs497c grader 1024 Sep 25 14:35 mail drwx------ 2 cs497c grader 1024 Sep 25 18:20 nsmail drwx------ 2 cs497c grader 1024 Sep 26 12:03 prog1 Permissions Links Owner Group size Last Filename Owner Modification Time ls –l: List File Attributes * The words total 7 indicates a total of 7 blocks are occupied by these files in the disk. * The first column shows the type and permissions associated with each file. * When you create a file, you automatically become its owner. * When opening a user account, the system administrator also assigns the user to some group. ls –l: List File Attributes * The fourth column stands for the group owner of the file. * The fifth column shows the size of the file in bytes. * The next set of three columns indicates the last modification time of the file. * The last column displays the filenames. * The –d (directory) option force ls to list the directory attributes rather than its contents. File Permissions $ ls -l chap3 chap5 hello.sh -rw-r--r-- 1 cs497c grader 306 Sep 26 11:55 chap3 -rw------- 1 cs497c grader 306 Sep 26 11:55 chap5 -rwxr-xr-x 1 cs497c grader 20 Sep 27 23:40 hello.sh * The first column represents the file permissions. * r indicates read permission, which means cat will display the file. * w indicates write permission, which means you can edit this file. File Permissions * x indicates execute permission; the file can be executed as a program. * There are three categories of users: owner, group, and others. owner’s permissions other’s permissions - r w x r - x r - x type of file group’s permissions * The first group (rwx) indicates the file owner can read, write, and execute this file. File Permissions * The second group (r-x) indicates the group can read and execute the file. * The third group (r-x) indicates others can read and execute the file.