![]() The pwd command is your Linux system's compass, in that it tells you where you are. ![]() You have created a new empty file, today.txt. Otherwise, this use offers a quick way to create a file without opening a text editor and then saving an empty file: Some programs require that a file exists to operate correctly, and this is one method of kickstarting such a process. The common use for touch is to create an empty file as a placeholder. Using touch to update last accessed time is actually an infrequent use of this command. Use touch to update the last accessed timestamp: 1 khess khess 114 Jul 23 19:09 students.txt The command's output displays the permissions, ownership, size, created or last accessed date/time, and the filename: If you list the contents of a directory in long format with: ![]() Its designated purpose is to update the timestamps on files. The touch command is another one that serves a dual purpose. You can concatenate as many files as you want into a single file using cat. $ cat grocerylist.txt todo_list.txt > Saturday.txt ![]() To use cat for its file concatenation powers, the general form of the command is:įor example, to redirect the contents of grocerylist.txt and todo_list.txt into the Saturday.txt file: If you want to see a file's contents, use the following format:įor example, you might type the following to display the contents of the system's passwd file on the screen: Printing the contents of files is by far the more frequent use of this command. The cat command is important as a basic command because it serves two very important functions: concatenating (merging) files (as the name suggests) and printing the contents of a file to the screen. As an example, look at the man page for the ls command. Use the Enter key to advance one line at a time, the ' b' key to go back, the Space bar to advance a full-screen page, and the ' q' key to exit the man page. The abbreviated command for referencing this documentation is, man and a screen-full of information appears before you. They're referred to as manual pages, as in read the manual. Linux has an extensive set of online documentation for your reference. The -a switch-or option, as it's called-shows you all files, even hidden ones. You now see several files beginning with a period. Hidden files in Linux begin with a period (. In your home directory, where you are now, you probably have hidden files. You've successfully listed the contents of the /etc directory, but you can actually list files in several different ways. The /etc ( et-see) directory is where a Linux system's configuration files live.Ī large number of files (over 200) appear on your screen. The ls command won't show you much in your home directory on a new system, so let's explore a directory that contains a lot of files and directories: /etc. If you simply type ls at a prompt ( $), you'll see all non-hidden files in your current directory, which is your home directory when you first log into a Linux system. The list ( ls) command is equivalent to the DOS DIR command, in that it lists files and directories. How well do you know Linux? Take a quiz and get a badge.Linux system administration skills assessment.A guide to installing applications on Linux.Download RHEL 9 at no charge through the Red Hat Developer program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |