3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel



Download 1.85 Mb.
View original pdf
Page23/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   19   20   21   22   23   24   25   26   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
[user@rhel-instance
]$ cd docs

[user@rhel-instance docs ln mysystemd/README MYREADME
[user@rhel-instance docs ls -l
total 20
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk
-rw-r--r--. 2 user user 13826 Feb 16 20:59 MYREADME
drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemd
-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouch
[user@rhel-instance docs ln MYREADME MYREADME2
[user@rhel-instance docs ls -l
total 36

Listing, creating, copying, and moving files, directories, links, and hard links
89
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-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 MYREADME2
drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemd
-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouch
drwxrwxr-x. 2 user user 6 Feb 16 20:35 test
Check 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 -l
total 36
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-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 MYREADME2
drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemd
lrwxrwxrwx. 1 user user 9 Feb 16 20:40 mysystemdlink ->
mysystemd
-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouch
drwxrwxr-x. 2 user user 6 Feb 16 20:35 test
Check 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).
Tip
When 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 Scripts
90
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.

Download 1.85 Mb.

Share with your friends:
1   ...   19   20   21   22   23   24   25   26   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page