Some file Commands

Remember that, in the informal talk, we are learning Linux1 also, but don't be afraid, it will not be difficult. The Unix is OS for programmers, and there is lot to learn from Unix for CS.

The Unix has directory structure, i.e., tree of folders and files, with a root. Following are some commands:

pwd: print working directory ls: list names of files and directories under current directory ls -l: Long list of the same, with group id, user id, size, date, name, and number of links associated.
 In the begin of ls -l's every row, rwx rwx rwx are permissions for user, group and others, for read, write, and execute. The "-" shows that permission is not granted. The first character as "-" says that it is a file and when it is "d", it means it is directory.

Some of the common commands for file operations are:


Table: Basic file related Linux commands
S.no. Command Description
1. $ cat hello.c displays the contents of hello.c file
2. $ cp hello.c ok.c copies first file into second
3. $ mv hello.c ok.c renames the first as second file
4. $ more hello.c displays hello.c page wise
5. $ head hello.c displays top 10 lines of hello.c
6. $ tail hello.c displays last 10 lines of hello.c
7. $ wc hello.c displays number of lines, words and characters in hello.c
8. $ rm filename removes the file, i.e., deletes it from the storage