Using symbolic links on a Linux system and other useful Linux commands for the user.

Posted: October 4, 2012. At: 7:03 PM. This was 5 years ago. Post ID: 4674
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

What is the difference between a hard link and a symbolic link? The output below shows the process of creating firstly a hard link and then a symbolic link. The hard link appears exactly the same as the original file; but the symbolic link displays as a link from the symlink to the original file. A hard link is the same as the original file. But a symlink is only a link to the file that it links to.

windows95    windows95-2  windows95-3  
[flynn@flynn-grid-runner Desktop]$ ln windows-95.png win95.png
[flynn@flynn-grid-runner Desktop]$ ln -s windows-95.png win95-2.png
[flynn@flynn-grid-runner Desktop]$ ls -hula win*png
lrwxrwxrwx 1 flynn flynn  14  04-10-12 04:53 pm win95-2.png -> windows-95.png
-rw-rw-r-- 2 flynn flynn 69K  21-09-12 12:46 am win95.png
-rw-rw-r-- 2 flynn flynn 69K  21-09-12 12:46 am windows-95.png
[flynn@flynn-grid-runner Desktop]$

After deleting the file that the two links reference the hard link is still the same size; but the symlink is highlighted in red on a black background. This means that the file it is linking to is gone.

[flynn@flynn-grid-runner Desktop]$ ls -hula win*png
lrwxrwxrwx 1 flynn flynn  14  04-10-12 04:53 pm win95-2.png -> windows-95.png
-rw-rw-r-- 1 flynn flynn 69K  21-09-12 12:46 am win95.png
[flynn@flynn-grid-runner Desktop]$

To easily find out what groups your user is a member of use the id command. This will display all of the groups that you are a member of and their GID.

[flynn@flynn-grid-runner Desktop]$ id
uid=1000(flynn) gid=1000(flynn) groups=1000(flynn),4(adm),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),100(users),109(lpadmin),127(sambashare)

This command will also perform this function with a nice; easily readable output.

[flynn@flynn-grid-runner Desktop]$ cat /etc/group | grep $LOGNAME
[flynn@flynn-grid-runner Desktop]$

To count how many users are logged into a Linux system; use the who command with the -q parameter.

[flynn@flynn-grid-runner Desktop]$ who -q
# users=1

This is the command used to view the /etc/passwd entry for a particular user. This is not the user I am using but you are welcome to try and break this password hash if you want.

[flynn@flynn-grid-runner Desktop]$ sudo cat /etc/shadow | grep hoshi

No comments have been made. Use this form to start the conversation :)

Leave a Reply