Académique Documents
Professionnel Documents
Culture Documents
I. INTRODUCTION
Linux is a file-oriented operating system. That means that many things an administrator must do on Linux can be traced down to
managing files on the Linux operating system. This chapter introduces you to essential file management skills. You learn how the Linux
file system is organized and how you can work with files and directories. You also learn how to manage links and compressed
or uncompressed archives.
Linux Command Essential File Management Tools 2
II. PROCEDURES
/usr: This directory contains operating system files only, to which normal
users normally do not need any write access. Putting it on a dedicated device
allows administrators to configure it as a read-only mount.
[root@localhost ~] #mount
To show available disk space on mounted devices; it includes most of the system mounts
[root@localhost ~] # df -Th
To show mounts and the relation that exists between the different mounts.
[root@localhost ~] # findmnt
[root@localhost ~] # du -h
Linux Command Essential File Management Tools 4
[root@localhost ~] # cd
[root@localhost ~] # pwd
[root@localhost ~] # touch filea fileb filec fileaa filebb filecc
A relative filename is relative to the current directory as shown with the pwd command.
It contains only the elements that are required to get from the current directory up to the item you need.
Links on Linux are like aliases that are assigned to a file. There are symbolic links,
and there are hard links
[root@localhost ~] # ls -l filename
[root@localhost ~] # stat filename
Just one important piece of information is not stored in the inode: the name. Names
are stored in the directory, and each filename knows which inode it has to address to
access further file information. These names are referred to as hard links.
When you create a file, you give it a name. Basically, this name is a hard link.
[root@localhost ~] # rm linkname
This removes the link. (Do not use -r or -f to remove links, even
if they are subdirectories.)
Linux Command Essential File Management Tools 7
To create an archive
[root@localhost ~] # tar -cf archivename.tar /files-you-want-toarchive
[root@localhost ~] # tar -cvf etc.tar /etc
To extract
[root@localhost ~] #tar -xvf /root/homes.tar
Exercise
1. Open a root shell on your server. By logging in, the home directory of user root will become the current directory, so all
relative filenames used in this exercise refer to /root/.
2. Type tar -cvf etc.tar /etc to archive the contents of the /etc directory.
3. Type file etc.tar and read the information that is provided by the command. This should look like the following:
[root@localhost ~] # file etc.tar
1. Which directory would you go to if you were looking for configuration files?
2. What command enables you to display a list of current directory contents, where the newest files are listed first?
3. Which command enables you to rename the file myfile to your file?
4. Which command enables you to wipe an entire directory structure, including all its contents?
5. How do you create a link to the directory /tmp in your home directory?
Linux Command Essential File Management Tools 9