Unix Flashcards
What do the columns in ls -l represent?
First Column − Represents the file type and the permission given on the file. Below is the description of all type of files.
Second Column − Represents the number of memory blocks taken by the file or directory.
Third Column − Represents the owner of the file. This is the Unix user who created this file.
Fourth Column − Represents the group of the owner. Every Unix user will have an associated group.
Fifth Column − Represents the file size in bytes.
Sixth Column − Represents the date and the time when this file was created or modified for the last time.
Seventh Column − Represents the file or the directory name.
What does every file begin with?
In the ls -l listing example, every file line begins with a d, -, or l. These characters indicate the type of the file that’s listed.
What does the ‘-‘ mean in ls -l
Regular file, such as an ASCII text file, binary executable, or hard link.
What does the ‘d’ mean in ls -l
Directory file that contains a listing of other files and directories.
What does the ‘l’ mean in ls -l
Symbolic link file. Links on any regular file.
What does the ‘p’ mean in ls -l
Named pipe. A mechanism for interprocess communications.
What does the ‘s’ mean in ls -l
Socket used for interprocess communication.
What does the ‘c’ mean in ls -l
Character special file. Raw input/output device file such as a physical hard drive.
What does the ‘b’ mean in ls -l
Block special file. Block input/output device file such as a physical hard drive.
What are the two metacharacters?
Metacharacters have a special meaning in Unix. For example, * and ? are metacharacters. We use * to match 0 or more characters, a question mark (?) matches with a single character.
What would this produce $ls ch*.doc?
ch01-1.doc ch010.doc ch02.doc ch03-2.doc
ch04-1.doc ch040.doc ch05.doc ch06-2.doc
ch01-2.doc ch02-1.doc c
How to display the contents of a file?
You can use the cat command to see the content of a file. Following is a simple example to see the content of the above created file −
How to count words in a file?
You can use the wc command to get a count of the total number of lines, words, and characters contained in a file.
$ wc filename
2 19 103 filename
What do the 4 columns produced by typing ‘wc filename’ mean?
Here is the detail of all the four columns −
First Column − Represents the total number of lines in the file.
Second Column − Represents the total number of words in the file.
Third Column − Represents the total number of bytes in the file. This is the actual size of the file.
Fourth Column − Represents the file name.
How to rename files?
mv old_file new_file