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


[user@rhel-instance ]$ ls -l var-files.txt



Download 1.85 Mb.
View original pdf
Page20/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   16   17   18   19   20   21   22   23   ...   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
]$ ls -l var-files.txt

ls: cannot access 'var-files.txt': No such file or directory

Listing, creating, copying, and moving files, directories, links, and hard links
85
To remove a full directory branch, including its contents, we may use the -r option, short for “recursive”:
[user@rhel-instance
]$ rm -r mydir/

[user@rhel-instance
]$ ls -l

total 0
Important Note
Be very careful when using recursive mode to delete things, as there is neither a recovery command for it nor a trash bin to keep files that have been removed in the command line.
Let’s take a look at the review table:
Table 3.4 – The directory commands
Now that we know how to create and delete directories in a Linux system, let’s start copying and moving content.
Copying and moving
Now, let’s copy some files to play with them using the cp (which stands for copy) command. We may get some powerful awk examples copied to our home directory:
[user@rhel-instance
]$ mkdir myawk

[user@rhel-instance
]$ cp /usr/share/awk/* myawk/

[user@rhel-instance
]$ ls myawk/ | wc -l

27
To copy more than one file at the same time, we have used globbing with the * sign. This works so that by specifying the files one by one, we can just type * for everything. We can also type the initial characters and then *, so let’s try this by copying some more files using globbing:
[user@rhel-instance
]$ mkdir mysystemd

[user@rhel-instance
]$ cp /usr/share/doc/systemd/* mysystemd/

[user@rhel-instance
]$ cd mysystemd/

[user@rhel-instance mysystemd]$ ls

Basic Commands and Simple Shell Scripts
86
20-yama-ptrace.conf CODING_STYLE DISTRO_PORTING ENVIRONMENT.

Download 1.85 Mb.

Share with your friends:
1   ...   16   17   18   19   20   21   22   23   ...   67




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

    Main page