Linux Bible. Christopher Negus

Чтение книги онлайн.

Читать онлайн книгу Linux Bible - Christopher Negus страница 47

Linux Bible - Christopher Negus

Скачать книгу

      To become an expert Linux user, you must be able to use the shell to type commands. This chapter focuses on the bash shell, which is the one that is most commonly used with Linux systems. You learned how commands are structured and how many special features, such as variables, command completion, and aliases, are used.

      The next chapter describes how to move around the Linux filesystem from the shell command line.

      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.

      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.

Illustration of the Linux filesystem organized as a hierarchy of directories and demonstrating how the directories are connected to the desktop, documents, and other subdirectories.
/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

Скачать книгу