Listing, creating, copying, and moving files,
directories, links, and hard links
89
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselectdrwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk-rw-r--r--. 3 user user 13831 Feb 16 20:32 MYREADME-rw-r--r--. 3 user user 13831 Feb 16 20:32 MYREADME2drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemd-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouchdrwxrwxr-x. 2 user user 6 Feb 16 20:35 testCheck the increasing number of references to the file (in bold in the previous example).
Now, let’s create a symbolic link to a directory with ln -s (with s for symbolic):
[user@rhel-instance docs ln -s mysystemd mysystemdlink[user@rhel-instance docs ls -ltotal 36drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselectdrwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk-rw-r--r--. 3 user user 13831 Feb 16 20:32 MYREADME-rw-r--r--. 3 user user 13831 Feb 16 20:32 MYREADME2drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemdlrwxrwxrwx. 1 user user 9 Feb 16 20:40 mysystemdlink -> mysystemd-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouchdrwxrwxr-x. 2 user user 6 Feb 16 20:35 testCheck how the symbolic link created is treated as a
different type when listing it, as it starts with l for link (in bold in the previous example) instead of d for directory (also in bold in the previous example).
TipWhen in doubt about whether to use a hard link or a symbolic link, use the symbolic link as the default choice.
Let’s check the review table:
Table 3.6 – Link commands
Basic Commands
and Simple Shell Scripts90
As you can see, creating links and symbolic links is super simple and can help us access the same file or directory from different locations. In the following section, we will cover how to pack and compress a set of files and directories.
Share with your friends: