Listing, creating, copying,
and moving files, directories, links,
and hard links85
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 -ltotal 0Important NoteBe 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 movingNow, 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 -l27To 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