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


[user@rhel-instance mysystemd]$ mv NEWS mynews



Download 1.85 Mb.
View original pdf
Page22/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   18   19   20   21   22   23   24   25   ...   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 mysystemd]$ mv NEWS mynews
[user@rhel-instance mysystemd]$ ls -l NEWS
ls: cannot access 'NEWS No such file or directory
[user@rhel-instance mysystemd]$ ls -l mynews
-rw-r--r--. 1 user user 451192 Feb 16 19:59 mynews
There is a special command for creating empty files, which is touch:
[user@rhel-instance mysystemd]$ cd

[user@rhel-instance
]$ ls -l docs/

total 4
drawer-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk
drwxrwxr-x. 2 user user 238 Feb 16 20:21 mysystemd
[user@rhel-instance
]$ touch docs/mytouch

[user@rhel-instance
]$ ls -l docs/

total 4
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk
drwxrwxr-x. 2 user user 238 Feb 16 20:21 mysystemd
-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouch
When applied to an existing file or folder, it will update its access time to the current one:
[user@rhel-instance
]$ touch docs/mysystemd

[user@rhel-instance
]$ ls -l docs/

total 4
drwxrwxr-x. 4 user user 35 Feb 16 20:08 myauthselect
drwxrwxr-x. 2 user user 4096 Feb 16 19:51 myawk
drwxrwxr-x. 2 user user 238 Feb 16 20:28 mysystemd
-rw-rw-r--. 1 user user 0 Feb 16 20:27 mytouch

Basic Commands and Simple Shell Scripts
88
Let’s check the review table:
Table 3.5 – Copying and moving commands
Now we know how to copy, delete, rename, and move files and directories, even full directory branches. Lets now take a look at a different way to work with them – links.
Symbolic and hard links
We can have the same file in two places using links. There are two types of links Hard links: There will be two entries (or more) to the same file in the filesystem. The content will be written once to disk. Hard links for the same file cannot be created in two different filesystems. Hard links cannot be created for directories Symbolic links: A symbolic link is created pointing to a file or directory in anyplace in the system.
Both are created using the ln (which stands for link) utility.
Let’s now create hard links:

Download 1.85 Mb.

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




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

    Main page