Devices — Your terminal, printer, and disk drive s are all treated as files. Directories — A directory is simply a file that contains other files. The following section explains the commands for creating, listing, copying, moving, and deleting files. This section also includes information on how to list the contents of a file and how to determine the nature of a file. Each of the command descriptions in this section includes an example of how to use the command. Try the examples as you read the text. Before you experiment with files, make sure that you are in your home directory.
Your system administrator established this directory for you at your account creation.
Chapter 3 Working With Files and Directories (Solaris Advanced User's Guide)
To avoid changes to parts of your system that other users expect to remain unchanged, perform the following tasks in your home directory. To make certain that you are in your home directory, type the cd change directory command. This command moves you to your home default directory. Then type the pwd print working directory command to display your current location within the file system. The directory displayed is your home directory:. Use the touch command to create an empty file.
If a file by the name you specify does not exist, the touch command creates an empty file. Now list the file with the ls command to verify that you've created it:. When you type the ls command by itself, it lists all the files in your current location. If you type the ls command with a specific file name, it lists only that file, if the file exists.
- jackson county missouri divorce court.
- registered sex offenders in the state of wyoming.
- dot cdl hazmat background check california;
- divorce for a man in texas!
For more information on listing files, see the man page ls 1. Use the cp command to copy tempfile to a file called copyfile :. Now list both files.
- If You Appreciate What We Do Here On TecMint, You Should Consider:.
- Find Files by Name!
- Log in to your FDO Account.
- free people finder by name and age;
- department of justice criminal background check.
Notice that copyfile is listed first. Files are listed in alphabetical order. Capital letters and numbers precede lowercase letters. For detailed information on copying files, see the man page cp 1. You can move and rename files by using the same command, mv move. In this example, use the mv command to rename tempfile to emptyfile :. For more information on moving and renaming files, see the man page mv 1.
How to Sort Output of ‘ls’ Command By Last Modified Date and Time
Use the rm remove command to delete copyfile , and verify the result with the ls command:. You cannot recover files that you have removed with rm. For more information on the rm 1 command, refer to the man Pages 1 : User Commands. Use the more command to display the contents of a file.
Type more and follow it with the name of the file to be displayed.
The contents of the file scroll down the screen. If the file is longer than one screen, this message appears:.
Creating a Test File
You can also use the cat command to display the contents of a file, but it displays the file contents rapidly without pausing. The cat concatenate command is more often used to join two or more files into one large file, as in this example:. For further information on the more 1 or cat 1 commands, refer to the man Pages 1 : User Commands.
Some files, such as binary files and executable files, are not printable and cannot be displayed on the screen. Use the file command to show the file type. This section describes the directory hierarchy that the Solaris operating environment uses to manage and organize files. Files are grouped into directories, and directories are organized in a hierarchy. In the following example, Figure 3—1 , each directory in the file system contains many subdirectories. When you initiate commands, you specify directories and files by including the names of the directories that contain the files or directories you want to work with.
The names of directories and the files beneath them, combined with slash separators, constitute a path name. All subdirectory names and file names within a directory must be unique. However, names within different directories can be the same. Path names for files work exactly like path names for directories. The path name of a file describes that file's place within the file-system hierarchy. The pwd command print working directory displays where you are in the file system hierarchy.
Your output might be different from the example, as your directory structure is different. Your working directory is your current location within the file-system hierarchy. Every user has a home directory. When you first open a terminal or a window, your initial location is your home directory. Your system administrator creates your home directory for you at your account creation.
The cd change directory command enables you to move around within the file-system hierarchy. When you type the cd command by itself, you return to your home directory. For example, you would type the following to change to the subdirectory music within your home directory:. With this configuration, you type the following command to change your working directory to the subdirectory music in your home directory. The symbol.. The command cd.. To create a new directory, type the mkdir command and follow it with the name of the new directory.
However, you can often use a shorter name that defines the file or directory relative to the current working directory. When you are in a parent directory, you can move to a subdirectory by using only the directory name and not the full path name. In the previous example, the command cd veggies uses the relative path name of the directory veggies.
Create several different subdirectories, and then move around within this directory structure. Use both full path names and relative path names, and confirm your location with the pwd command.
Resolve issues caused by changing the permissions of items in your home folder
You rename a directory by moving it to a different name. Use the mv command to rename directories. In this example, the directory carrots is moved from veggies to veggies2 with the mv command. Use the cp -r command to copy directories and the files they contain:. The command in the previous example copies all files and subdirectories within the directory veggies to a new directory veggies3. This is a recursive copy, as designated by the -r option.
If you attempt to copy a directory without using this option, the system displays an error message. To remove an empty directory, use the rmdir command as follows:. If the directory still contains files or subdirectories, the rmdir command does not remove the directory. To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r.