1 From your desktop, switch to the third virtual console and log in to your user account. Run a few commands. Then exit the shell and return to the desktop.
2 Open a Terminal window and change the font color to red and the background to yellow.
3 Find the location of the mount command and the tracepath man page.
4 Type the following three commands, and then recall and change those commands as described: $ cat /etc/passwd $ ls $HOME $ dateUse the command-line recall feature to recall the cat command and change /etc/passwd to /etc/group.Recall the ls command, determine how to list files by time (using the man page), and add that option to the ls $HOME command line.Add format indicators to the date command to display the date output as month/day/year.
5 Run the following command, typing as few characters as possible (using tab completion): basename /usr/share/doc/
6 Use the cat command to list the contents of the /etc/services file and pipe those contents to the less command so that you can page through it (press q to quit when you are finished).
7 Run the date command in such a way that the output from that command produces the current day, month, date, and year. Have that read into another command line, resulting in text that appears like the following (your date, of course, will be different): Today is Thursday, December 19, 2019.
8 Using variables, find out what your hostname, username, shell, and home directories are currently set to.
9 Create an alias called mypass that displays the contents of the /etc/passwd file on your screen in such a way that it is available every time you log in or open a new shell from your user account.
10 Display the man page for the mount system call.
CHAPTER 4 Moving Around the Filesystem
IN THIS CHAPTER
Learning about the Linux filesystem
Listing file and directory attributes
Making files and directories
Listing and changing permission and ownership
Making copies and moving files
The Linux filesystem is the structure in which all of the information on your computer is stored. In fact, one of the defining properties of the UNIX systems on which Linux is based is that nearly everything you need to identify on your system (data, commands, symbolic links, devices, and directories) is represented by items in the filesystems. Knowing where things are and understanding how to get around the filesystem from the shell are critical skills in Linux.
In Linux, files are organized within a hierarchy of directories. Each directory can contain files as well as other directories. You can refer to any file or directory using either a full path (for example, /home/joe/myfile.txt
) or a relative path (for example, if /home/joe
were your current directory, you could simply refer to the file as myfile.txt
).
If you were to map out the files and directories in Linux, it would look like an upside-down tree. At the top is the root directory (not to be confused with the root user), which is represented by a single slash (/
). Below that is a set of common directories in the Linux system, such as bin
, dev
, home
, lib
, and tmp
, to name a few. Each of those directories, as well as directories added to the root directory, can contain subdirectories.
Figure 4.1 illustrates how the Linux filesystem is organized as a hierarchy. To demonstrate how directories are connected, the figure shows a /home
directory that contains a subdirectory for the user joe
. Within the joe
directory are Desktop
, Documents
, and other subdirectories. To refer to a file called memo1.doc
in the memos
directory, you can type the full path of /home/joe/Documents/memos/memo1.doc
. If your current directory is /home/joe/
, refer to the file as Documents/memos/memo1.doc
.
FIGURE 4.1 The Linux filesystem is organized as a hierarchy of directories.
Some of these Linux directories may interest you:
/bin |
Contains common Linux user commands, such as ls , sort , date , and chmod .
|
/boot | Has the bootable Linux kernel, initial RAM disk, and boot loader configuration files (GRUB). |
/dev |
Contains files representing access points to devices on your systems. These include terminal devices (tty* ), hard disks (hd* or sd* ), RAM (ram* ), and CD-ROM (cd* ). Users can access these devices directly through these device files; however, applications often hide the actual device names to end users.
|
/etc | Contains administrative configuration files. Most of these files are plain-text files that, given the user has proper permission, can be edited with any text editor. |
/home |
Contains directories assigned to each regular user with a login account. (The root user is an exception, using /root as his or her home directory.)
|
/media |
Provides a standard location for automounting devices (removable media in particular). If the medium has a volume name, that name is typically used as the mount point. For example, a USB drive with a volume name of myusb would be mounted on /media/myusb .
|
/lib |
Contains shared libraries needed by applications in /bin and /sbin to boot the system.
|
/mnt |
A common mount point for many devices before it was supplanted by the standard /media directory. Some bootable Linux systems still use this directory to mount hard disk partitions and remote filesystems. Many people still use this directory to temporarily mount local or remote filesystems, which are not mounted permanently.
|
/misc | A directory sometimes used to automount filesystems upon request. |
/opt | Directory structure available to store add-on application software. |
/proc | Contains information about system resources. |
/root |
Represents the root user's home directory. The home directory for root does not reside beneath /home
|