Linux Command – apropos


Apropos could be the most helpful command for a beginner. Almost every command has a manual page that gives description about what it does along with its advanced options. But the man command  cannot do much for a beginner who doesn’t know the name of the command he/she wants to know about. This is where apropos comes to the rescue.

Apropos searches the man pages for keywords provided by the user. Its like google for man pages. So you can just type apropos to know more about.

Example

amrita@amrita-desktop:~$ apropos gcc
c89-gcc (1)          - ANSI (1989) C compiler
c99-gcc (1)          - ANSI (1999) C compiler
gcc (1)              - GNU project C and C++ compiler
gcc-4.4 (1)          - GNU project C and C++ compiler
i486-linux-gnu-gcc (1) - GNU project C and C++ compiler
i486-linux-gnu-gcc-4.4 (1) - GNU project C and C++ compiler

It is a good practice to read the man page of any new command you learn. So open up your shell and man apropos now itself 🙂

Linux Commands – File Operations – Continued


Renaming files

There is no special command to rename a file or directory. But we can use mv to do the same.

Copying and Removing directories

Using -R option we can apply cp and rm to directories also.

Using -f in case of rm forces the delete.

Example


vishnu@bios-11:~$ ls
Desktop    Downloads         Music     Public     Ubuntu One
Documents  examples.desktop  Pictures  Templates  Videos
vishnu@bios-11:~$ mkdir test
vishnu@bios-11:~$ ls
Desktop    Downloads         Music     Public     test        Videos
Documents  examples.desktop  Pictures  Templates  Ubuntu One
vishnu@bios-11:~$ mv test/ temp
vishnu@bios-11:~$ ls
Desktop    Downloads         Music     Public  Templates   Videos
Documents  examples.desktop  Pictures  temp    Ubuntu One
vishnu@bios-11:~$ cp -R temp Documents/
vishnu@bios-11:~$ ls
Desktop    Downloads         Music     Public  Templates   Videos
Documents  examples.desktop  Pictures  temp    Ubuntu One
vishnu@bios-11:~$ rm temp
rm: cannot remove `temp': Is a directory
vishnu@bios-11:~$ rm -Rf temp
vishnu@bios-11:~$ ls
Desktop    Downloads         Music     Public     Ubuntu One
Documents  examples.desktop  Pictures  Templates  Videos
vishnu@bios-11:~$ cd ./Documents/
vishnu@bios-11:~/Documents$ ls
blog  docs  learn  task list  temp
vishnu@bios-11:~/Documents$ rmdir temp
vishnu@bios-11:~/Documents$ ls
blog  docs  learn  task list
There are a lot of options for almost every command. So it is a good practise to read the man page of every new command we learn 🙂

Linux Command – cal


What it does : Displays the calendar  of the current month.

You can even specify the year or the month.

Example

cal

Now here is something interesting. Checkout September in the example given below.

Find out why that happened by referring the man page of cal.

Thanks to Anish Chandran Sir for showing this to me 🙂

Linux Commands – File Operations


Command : cp <source> <destination>

What it does: Copies source file or directory to destination.

Command : mv <source> <destination>

What it does: Moves source file or directory to destination.

Command : rm <file>

What it does: Removes the file or directory.

Command : mkdir <dir>

What it does : Makes a directory named <dir>.

Command : rmdir <dir>

What it does: Removes <dir> if empty.

Example


bios@bios-mac-7:~$ cd ./Vishnu\ RKM/
bios@bios-mac-7:~/Vishnu RKM$ ls
error.png       plugin prob.odt        terminal_eror.png
lock error.png  suggested plugins.png
bios@bios-mac-7:~/Vishnu RKM$ mkdir backup
bios@bios-mac-7:~/Vishnu RKM$ ls
backup     lock error.png   suggested plugins.png
error.png  plugin prob.odt  terminal_eror.png
bios@bios-mac-7:~/Vishnu RKM$ cp plugin\ prob.odt ./backup/
bios@bios-mac-7:~/Vishnu RKM$ ls
backup     lock error.png   suggested plugins.png
error.png  plugin prob.odt  terminal_eror.png
bios@bios-mac-7:~/Vishnu RKM$ cd ./backup/
bios@bios-mac-7:~/Vishnu RKM/backup$ ls
plugin prob.odt
bios@bios-mac-7:~/Vishnu RKM/backup$ cd ./..
bios@bios-mac-7:~/Vishnu RKM$ rmdir backup/
rmdir: failed to remove `backup/': Directory not empty
bios@bios-mac-7:~/Vishnu RKM$ cd ./backup/
bios@bios-mac-7:~/Vishnu RKM/backup$ rm plugin\ prob.odt
bios@bios-mac-7:~/Vishnu RKM/backup$ ls
bios@bios-mac-7:~/Vishnu RKM/backup$ cd ./..
bios@bios-mac-7:~/Vishnu RKM$ rmdir backup/
bios@bios-mac-7:~/Vishnu RKM$ ls
error.png       plugin prob.odt        terminal_eror.png
lock error.png  suggested plugins.png
bios@bios-mac-7:~/Vishnu RKM$ mkdir pics
bios@bios-mac-7:~/Vishnu RKM$ cp *.png ./pics/
bios@bios-mac-7:~/Vishnu RKM$ rm *.png
bios@bios-mac-7:~/Vishnu RKM$ ls
pics  plugin prob.odt
bios@bios-mac-7:~/Vishnu RKM$ cd ./pics/
bios@bios-mac-7:~/Vishnu RKM/pics$ ls
error.png  lock error.png  suggested plugins.png  terminal_eror.png
bios@bios-mac-7:~/Vishnu RKM/pics$ cd ./..
bios@bios-mac-7:~/Vishnu RKM$ mkdir files
bios@bios-mac-7:~/Vishnu RKM$ ls
files  pics  plugin prob.odt
bios@bios-mac-7:~/Vishnu RKM$ mv plugin\ prob.odt ./files/
bios@bios-mac-7:~/Vishnu RKM$ ls
files  pics
bios@bios-mac-7:~/Vishnu RKM$ mkdir temp
bios@bios-mac-7:~/Vishnu RKM$ ls
files  pics  temp
bios@bios-mac-7:~/Vishnu RKM$ rmdir temp
bios@bios-mac-7:~/Vishnu RKM$ ls
files  pics

Linux Command – man


What it does: Displays the manual page of a command.

To exit form manual page, press q.

If you need to know more about a command, all you have to do is type “man <command>” and press enter

Try man man to know more about man 🙂

bios@bios-11:~$ man man

Manual pages are really big so I’m not adding the page to my blog. Try em out.