I would like to share in this series of posts all the interesting tips in UNIX i’ve came across till date.
- To understand read, write, execute permissions for a file
ls -l file.dat -rw-r--r-- 1 root users 1656 Mar 22 00:27 file.dat
The first letter – stands for a normal file, d for directory, c or b for a device, l for a link to another file. Then comes read write execute permissions for user, group and others respectively.
- Repeat last command !!. Example say you want to install vim in ubuntu. apt-get install vim this will fail because you do not have root permissions sudo !! will install it.
- To check if a given command executed successfully or not, type the following command.
echo $?
Zero (0) result represents success and any Non-zero result represents failure.
- To view latest output appended to a file as it grows
tail -f path/to/file
- To get name server information for domains by querying DNS
nslookup -type=ALL domain.name
- Two or more commands can be combined with the && operator. However the succeeding command is executed if and only if the previous one is true. If you want to execute both irrespective of first outcome use & instead.
ls && date # lists the contents of the directory first and then gives the system date.
- To get list of all the installed packages
dpkg -l
- The colour code of the files is as follows.
Blue : Directory file White : Normal file Green : Executable file Yellow : Device file Magenta : Picture file Cyan : Link file Red : Compressed file
- To check disk space, use the following command
df -h
- To link to a file or directory
ln -s target_file link_name ln -sd target_directory link_name
-s is symbolic link – removing the link doesn’t remove the original file. Without -s is hard link – removing the link will also remove the original file!!
- more to come later
- more to come later