[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ A ] [ B ] [ C ] [ D ] [ next ]
In general, all information on your Linux system is stored in files. Although you often use separate commands to manipulate directories and links, both are basically specialized types of files.
This chapter covers the basic tasks, such as creating, selecting, copying and deleting directories and files. It also explains how to view and create links, and how to change file attributes.
[Note]
You cannot manipulate files unless you have permission to do so. This limitation is one of the major differences between Linux and many popular operating systems. See Changing Permissions, Section 9.19.
On the desktop, you can use the gnome Midnight Commander for the most common file functions.
However, for a complete set of options, you must use the command line. In fact, a few tasks, such as merging files can only be done from the command line.
Open a program, such as a text editor.
From the menu, select File > Save. The Save dialogue window opens.
Use the directory tree to select a directory.
Enter the file name. Then select the Save button.
Type: touch file.
If no path is entered, then the files are created in the present directory.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Right-click on the directory pane. A pop-up menu displays.
From the menu, select New Directory. The Create a new directory window opens.
Enter a name for the new directory. Select the ok button when you are finished.
[Note]
You may need to select Edit > Rescan directory before the new directory displays in the gnome Midnight Commander.
Type: mkdir options directory .
The mkdir Command (Make Directory)
+-------------------------------------------------------------------+
| Option | Action | Comment |
|-------------+------------------------------+----------------------|
| |Sets permissions for new |See Changing |
|-m mode |directory in absolute mode. |Permissions in |
| | |Absolute Mode. (***) |
|-------------+------------------------------+----------------------|
| * -p |Creates any parent directories| |
| * --parents|if they do not already exist. | |
+-------------------------------------------------------------------+
***) Changing Permissions in Absolute Mode, Section 9.19.4.2.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager. In both cases, the gnome
Midnight Commander opens, displaying your home directory. img/Files-3.png
Select a file. Do one of the following:
Left-click on an icon with the mouse. If you want to select another file, left-click on its icon while pressing the Ctrl key.
Hold down the left mouse button, and drag the cursor across the files you want to select. A box displays around the files as they are selected.
Select an item from the menu:
Edit > Select All: Selects all files in the current window.
Edit > Select Files: Selects files that match the regular expression that you enter in a dialogue. Using Metacharacters or Wild Cards, Section 5.3.6.
Edit > Invert Selection: Deselects files that are currently selected and selects files that are currently deselected. No matter how you choose files, their icon text is highlighted when selected.
Either:
Enter file names after a command. Put a space between them. or
Use metacharacters in regular expressions. For example, *.jpg selects all files in the directory with a .jpg extension. See Using Metacharacters or Wild Cards, Section 5.3.6. Be careful when using moving or deleting files with metacharacters.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Select the files to copy. See Selecting Files From the Desktop, Section 9.5.
Right-click on one of the selected files. A pop-up menu displays.
Select Copy from the pop-up menu. The Copy window displays.
Enter the folder to copy the files to. You can type the folder's path or select it using the Browse button.
If you wish, select Copy options from the Advanced tab. The Advanced options are:
Preserve Symlinks: If a link is copied, it points to the original file.
Follow links: The original file is copied, instead of the link. The original file is probably larger than the link.
Preserve file attributes: Information from the original is transferred to the copy. Permissions are transferred even if this option is not selected.
Recursively copy subdirectories: If a directory is being copied, then all sub-directories in it are also copied. By default, only Preserve file attributes is selected.
Select the ok button to copy the file.
[Note]
If you cannot copy, then you do not have write permission to the target directory or file name. See Changing Permissions, Section 9.19.
[Note]
You can also drag selected files with the left mouse button to any folder in any open Midnight Commander window.
Type: cp options source target .
The cp Command (Copy)
+-------------------------------------------------------------------+
| Option | Action | Comments |
|-------------------+-----------------------+-----------------------|
| * -a |Gives target files the | |
| * --archive |same attributes as the | |
| |source files. | |
|-------------------+-----------------------+-----------------------|
| * -b |Backs up files that | |
| * --backup |will be over written. | |
|-------------------+-----------------------+-----------------------|
| | |No confirmation is |
| * -f |Over writes any |asked. Consider using |
| * --force |existing files with the|with -i or -b to avoid |
| |copy. |over writing files by |
| | |accident. |
|-------------------+-----------------------+-----------------------|
| * -i |Asks for confirmation | |
| * --interactive |before over writing any| |
| |files. | |
|-------------------+-----------------------+-----------------------|
| * -p |Includes the original |Attributes include the |
| * --preserve |file's attributes. |owner, group, |
| | |permissions and dates. |
|-------------------+-----------------------+-----------------------|
| |Copies parent | |
| * -P |directories to | |
| * --parents |sub-directories of the | |
| |target directory. | |
|-------------------+-----------------------+-----------------------|
| * -r, -R |Copies sub-directories | |
| * --recursive |and their contents. | |
|-------------------+-----------------------+-----------------------|
| |Makes the target a | |
| * -s |symbolic link to the |See Working With |
| * --symbolic-link|source file, instead of|Symbolic Links. (***) |
| |a copy. | |
|-------------------+-----------------------+-----------------------|
| |Copies only files whose| |
| * -u |date are the same or | |
| * --update |newer than similarly | |
| |named ones in the | |
| |target directory. | |
|-------------------+-----------------------+-----------------------|
| * -v |Displays file names as | |
| * --verbose |they are copied. | |
+-------------------------------------------------------------------+
Working With Symbolic Links, Section 9.16.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Select the files to move. See Selecting Files From the Desktop, Section 9.5.
[Warning]
Paths, aliases, links, and other features may be affected by moving a file.
Right-click on one of the selected files. A pop-up menu displays
Select Move from the pop-up menu.The Move window opens.
Select the folder to copy the files to. You can enter the folder or select it using the Browse button.
If you wish, select Preserve symlinks from the Advanced tab. With this option, symbolic links are automatically updated.
Select the ok button to move the file.
[Note]
If you cannot move a file, then you do not have write permission in the target directory. See Changing Permissions, Section 9.19.
[Note]
You can also drag selected files with the left mouse button to the desktop or to folders.
Type: mv options source target .
The target can be a file or a directory.
This command can have three possible results:
If the target file or directory does not already exist, the source file or directory is renamed.
If the target file or directory already exists, then it is over written by the source. The original file is deleted unless the -b option is used to back it up.
If the target is a directory, then the source files are moved to the directory.
The mv Command (Move)
+-------------------------------------------------------------------+
| Option | Action | Comments |
|-----------------+----------------------------+--------------------|
| * -b |Backs up target files that | |
| * --backup |will be over written. | |
|-----------------+----------------------------+--------------------|
| | |No confirmation is |
| | |asked. |
| * -f |Over writes any existing | |
| * --force |files with the copy. |Consider using with |
| | |-i or -b to prevent |
| | |over writing by |
| | |mistake. |
|-----------------+----------------------------+--------------------|
| * -i |Asks for confirmation before| |
| * --interactive|over writing any file. | |
|-----------------+----------------------------+--------------------|
| |Moves only files whose date | |
| * -u |are the same or newer than | |
| * --update |similarly named ones in the | |
| |target directory. | |
|-----------------+----------------------------+--------------------|
| * -v |Displays file names as they | |
| * --verbose |are moved. | |
+-------------------------------------------------------------------+
Select Properties from an icon's pop-up menu. The Properties window displays.
Enter the new name in the File Name field.
[Warning]
Paths, aliases, links, and other features may be disabled if a file is renamed.
Select the ok button to rename the files.
To rename files, use the mv (move) command. See Moving Files From the Command Line, Section 9.10.
Type: mv options source target .
To keep the renamed file in its original directory, keep the destination's path name the same as the original, except for the file name.
You can permanently delete a file or sent it to the Trash in case you want to restore it later.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Select the files to delete.
Do one of the following:
Select Delete from one of the selected file's pop-up menu.
Select Delete from the File menu of the Midnight Commander. In both cases, the
Delete window displays. img/Files-9.png
Select the Yes button to delete the selected files.
The trash bin is a directory (.gnome-desktop/Trash in your home directory) for storing deleted files that you might want to restore again.
All users have their own trash bins.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Select the files to move to the Trash.
Do one of the following:
Select Move to Trash from the pop-up menu of one of the selected files.
Drag the selected files to the Trash icon on the desktop.
Move the selected files to Desktop/Trash in the same way that you would move any files anywhere. See Moving Files From the Desktop, Section 9.9
[Note]
From the desktop, you cannot set the gnome Trash to empty when it reaches a certain size.
However, you could use the cron command to delete its contents at a regular time. .
Your Trash folder behaves exactly the same as any other folder on your desktop.
To restore files, move them from the Trash folder to another folder. See Moving Files From the Desktop, Section 9.9.
Type: rm file .
If you want the option to recover files, move them to a storage directory. You can use the.gnome-desktop/Trash directory in your home directory. This is the directory in which files are stored when you send them to the Trash on the desktop.
[Note]
You can also use rmdir to remove empty directories. However, in most cases, you can use rm -r as an alternative and save yourself the trouble of learning another command.
The rm Command (Remove)
+-------------------------------------------------------------------+
| Option | Action | Comments |
|-----------------+--------------------------+----------------------|
| * -d |Removes any |Only the root user can|
| * --directory |sub-directories and their |use this option. |
| |contents. | |
|-----------------+--------------------------+----------------------|
| * -f |Removes all files without | |
| * --force |confirmation. | |
|-----------------+--------------------------+----------------------|
| * -i |Asks for confirmation | |
| * --interactive|before removing each file.| |
|-----------------+--------------------------+----------------------|
| * -r, -R |Removes sub-directories |May cause accidental |
| * --recursive |and their contents. |deletion of files. |
|-----------------+--------------------------+----------------------|
| * -v |Displays file names as | |
| * --verbose |they are removed. | |
+-------------------------------------------------------------------+
Files cannot be merged from the desktop. From the command line, you can use a viewing command with a redirection operator or diff3 .
You can a viewing command with redirection operator to merge files. For
example, if you are using cat :
To merge separate files into a new file, type: cat files > merged_file .
To add files to an existing file, type: cat sources >> target .
Separate file names by a space.
You could also use less or more to merge files. Viewing Files From the Command Line, Section
8.6.
The diff3 command can be used for comparing files. However, you can also use the command to merge files. This function is especially useful when two versions of a file have been worked on separately.
Type: diff3 target original version .
Note:
The original file is the one that the other two are based on.
The version file is the first modified version of the original file.
The target file is the second modified version of the original file.
The contents of each file displays on the screen.
The order of the files is important. The command compares the original and the version file, then the target and the version file.
A change in the target file always over rides a change in the version file.
A link is a small file that points to another file. When a command is used by a link, it is passed on directly to the original file.
A link is useful when you need a file in two places and/ or when you want to save disk space. However, if the original file is moved or deleted, the symbolic link no longer works.
Links are also used to create launchers on the desktop. Because the launchers are links, deleting them does not delete the file to which they point.
Linux uses two types of links:
Absolute links (also called hard links) get their name because of how they are stored on the filesystem. For the average user, hard links are more limited than symbolic links. An absolute link must be on the same filesystem as the original file, and is not recognized by ls and other commands.
Symbolic links (also called soft links) are copied, moved, or deleted like other files. Deleting a link does not affect the original file. However, the creation of symbolic links and administering the connections between them requires a little more care than with other files.
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Do one of the following:
Select the Custom icon from the tool bar.
Select Layout > Custom View from the menu. In all cases, files that are links have an l as the first character in the Permissions column.
The ls command displays the contents of the working directory. To display the symbolic links in the current directory, open a command line and type: ls -l .
The attributes of each file are displayed on a separate line. If a file is a link, then the first character is an l .
In addition, any symbolic link is displayed with the original file beside it. For example, if the original file was ToDo and the link was Monday, then the entry for the link would be: Monday -> ToDo.
You can also use the --color option to display symbolic links and other file types in their own color, and -F to display symbolic links with the at sign (@) at the end of them,
Open the gnome Midnight Commander. Do one of the following:
From the workspace, select the Home directory launcher.
From the menu, select Programs > File Manager.
Select the files to link. See Selecting Files From the Desktop, Section 9.5.
Right-click on one of the selected files. The pop-up menu opens
Select Symlink from the pop-up menu. A dialogue window opens.
If necessary, enter the name of the original file. In most cases, the name is entered for you.
Enter the file name for the symbolic link. If the file name already exists, a
confirmation window opens. Select the Cancel button to avoid over writing the
file. If the file name entered does not conflict with an existing one, then
the symbolic link is created. The icon for the link has an arrow in the lower
right corner. img/Files-12.png
You can use the cp -l command to create an absolute link or the ln -s command to create a symbolic link. Usually, you will want to create a symbolic link instead of an absolute link.
To add a single link with a different name from the original file, type:
ln -s options file link .
To add a link with the same file name as the original file but in a different directory, type: ln -s options file directory .
If you enter more than one original file name, leave a space between the names.
The ln Command (Link)
+-------------------------------------------------------------------+
| Option | Action | Comments |
|-----------------+------------------+------------------------------|
| * -b |Backs up files | |
| * --backup |before over |Useful with the -S option. |
| |writing. | |
|-----------------+------------------+------------------------------|
| * -f |Over writes files |Use with the -b option to |
| * --force |if necessary. |avoid accidentally over |
| | |writing important files. |
|-----------------+------------------+------------------------------|
| * -i |Prompts for | |
| * --interactive|permission before | |
| |each action. | |
|-----------------+------------------+------------------------------|
| * -S suffix |Adds a suffix to | |
| * --suffix |backup files. |The default suffix is . |
| suffix | | |
|-----------------+------------------+------------------------------|
| * -s |Creates a symbolic|Without this option, a hard |
| * --symbolic |link. |link is created. |
|-----------------+------------------+------------------------------|
| * -v |Displays actions | |
| * --verbose |on screen. | |
+-------------------------------------------------------------------+
Each file in Linux has an owner. This attribute gives users some privacy. It can also be used by the root owner to protect files from casual use or accidental damage.
The owner of a file is usually the user who created the file. However, the owner may be changed by either the present owner or the root user.
Valid owners are listed in the /etc/passwd file.
An owner is identified by the user account or a user id .
From the file's pop-up menu, select Properties. The Properties window displays.
Select the Permissions tab.
Edit the Owner field. You must enter a valid user. If you do not, an error message displays and the Properties window closes.
Select the ok button to change the settings and close the window.
Type: chown options owner files .
The owner can be identified by the user account or the user id .
To copy the owner from another file, type: chown options --reference= source target .
The chown Command (Change Owner)
+-------------------------------------------------------------------+
| Option | Action |Comments|
|--------------------+-------------------------------------+--------|
| * -c |Displays information about files that| |
| * --changes |are changed. | |
|--------------------+-------------------------------------+--------|
| |Changes the ownership of both | |
|--dereference |symbolic links and the files to which| |
| |they point. | |
|--------------------+-------------------------------------+--------|
| * -h |Changes the ownership of a symbolic | |
| * --no-dereference|link, but not of the file to which it| |
| |points. | |
|--------------------+-------------------------------------+--------|
|--reference= file |Copies owner from the file listed. | |
|--------------------+-------------------------------------+--------|
| * -r |Changes ownership of sub-directories | |
| * --recursive |and their contents. | |
|--------------------+-------------------------------------+--------|
| * -v |Displays actions on screen. | |
| * --verbose | | |
+-------------------------------------------------------------------+
A group is a collection of users who have the same access to devices and files on the system. Each file in Linux is assigned to a group.
In most cases, a file is assigned to its owner's main group, which is usually the same as the owner's account name. However, users may belong to more than one group.
Valid owners are listed in the /etc/group file.
The group may be changed by either the present owner or the root user.
The group attribute lets the owner define whether other users can work with the file, and what they can do with it. It can also be used by the root owner to protect files from casual use or accidental damage.
From the file's pop-up menu, select Properties. The Properties window displays.
Select the Permissions tab.
Edit the Group field. You type in a group, or select one from the pull-down list. You must enter a valid group. If you do not, an error message displays and the Properties window closes.
Select the ok button to change the settings and close the window.
Use the chgrp (change group) command. Only the owner of a file or the root user can change the group. Valid groups are listed in /etc/ group.
Type: chgrp options group files .
The group can be identified by name or group id .
To copy the group from another file, type: chgrp options --reference= source target .
The chgrp Command (Change Group)
+-------------------------------------------------------------------+
| Option | Action |Comments|
|---------------+------------------------------------------+--------|
| * -c |Displays information about changed files. | |
| * --changes | | |
|---------------+------------------------------------------+--------|
|--reference= |Copies the group from the file listed. | |
|file | | |
|---------------+------------------------------------------+--------|
| * -r |Changes the group for sub-directories and | |
| * --recursive|their contents. | |
|---------------+------------------------------------------+--------|
| * -v |Displays actions on screen. | |
| * --verbose | | |
+-------------------------------------------------------------------+
Permissions define how users can work with a file or directory - or whether they can work with it at all. Permissions are also called access rights, or file or access permissions.
The three types of permissions are:
Read: Permission to view. For a directory, this permissions means that you can view the contents. Abbreviated to r in file attributes.
Write: Permission to change. For a directory, this permission means that you can add or remove files form it. Abbreviated to w in file attributes.
Execute: Permission to run if the file is a binary. For a directory, this permission means that you can view the file attributes and change into the directory or its sub-directories. Abbreviated to x in file attributes.
A hyphen ( - ) in the list of file attributes indicates that no permission is set.
In addition, a file may be set as Sticky. That means that only the user or root user can delete it.
Permissions are set for three categories of users:
The owner: Usually, the owner can read, write and execute. However, you may, for example, choose not to give yourself write permission to prevent the accidental overwriting of a file. The owner can be identified by either his or her user account, or by the user account id ( uid ).
[Warning]
Depending on the file, setting the user id to the root user can create security problems.
The group: A group that the owner belongs to. The group can be identified by its name or by the group id ( uid ). Usually, it is the owner's main group, which has the same name as the owner's user account.
Other: Other users on the system. On many systems, other users have read permission for system files, but cannot read files in other users' home directories.
[Note]
The root user can read, write, and execute all files on the system.
Occasionally, you may find some graphic tools that do not allow the root user complete access. However, the root user can always access all files from the command line.
From the file's pop-up menu, select Properties. The Properties window displays.
Select the Permissions tab.
Type: ls -l file .
The first attributes on each line are the type of file and the permissions. For example, a typical file might display: -rwxr-xr-- :
The first character shows the type of file, using
- for a file.
d for directory.
l for link.
The other nine characters are the permissions:
The first three are for the owner, the second three for the group, and the third three for other users.
Starting from the left, the order of permissions in each group are read, write and execute permissions.
From the file's pop-up menu, select Properties. The Properties window displays.
Select the Permissions tab.
Set read, write, and execute permissions by selecting them for each category of user with the mouse. You can view the current owner and group in the File Ownership pane. Continually select the button for the user or group id to cycle through valid settings. The changes display in the Current mode line at the top of the Permissions tab.
Select the ok button to change the settings and close the window.
The chmod command has two modes: the symbolic (or character) and the absolute (or octal) mode.
As well as the usual options in any command, the symbolic mode uses a series of individual arguments. Use the symbolic mode if you want to assign the permissions carefully, and in full.
By contrast, the absolute mode uses octal notation to reduce the arguments in the commands to three characters. Despite its name, absolute mode is quick and efficient once you learn it.
Type: chmod options group action permissions file .
The possible entries for each part of this command is explained in one of the tables below.
The group and permissions arguments can use more than one entry. For example, you could use ug in the group argument to set permissions for both the user and the group.
The chmod Command (Change Permissions): Options
+-------------------------------------------------------------------+
| Option | Action |Comments|
|---------------+------------------------------------------+--------|
| * -c |Displays information about changed files. | |
| * --changes | | |
|---------------+------------------------------------------+--------|
|--reference= |Copies permissions from the file listed. | |
|file | | |
|---------------+------------------------------------------+--------|
| * -R |Applies changes to sub-directories and | |
| * --recursive|their contents. | |
|---------------+------------------------------------------+--------|
| * -v |Displays information about all files. | |
| * --verbose | | |
+-------------------------------------------------------------------+
The chmod Command (Change Permissions):
Group Settings for Symbolic Mode
+-------------------------------------------------------------------+
| Group |Argument|
|----------------------------------------------------------+--------|
|All. User, Group and Others. |a |
|----------------------------------------------------------+--------|
|Group. |g |
|----------------------------------------------------------+--------|
|Other users on the system who do not belong to the user's |o |
|group. | |
|----------------------------------------------------------+--------|
|User. The owner of the file. |u |
+-------------------------------------------------------------------+
The chmod Command (Change Permissions):
Action Settings for Symbolic Mode
+-------------------------------------------------------------------+
| Action |Argument|
|----------------------------------------------------------+--------|
|Adds permission. |+ |
|----------------------------------------------------------+--------|
|Removes permission. |- |
|----------------------------------------------------------+--------|
|Sets only the permissions specified and removes all other |= |
|permissions. | |
+-------------------------------------------------------------------+
The chmod Command (Change Permissions):
Permission Settings for Symbolic Mode
+-------------------------------------------------------------------+
| Action |Argument|
|----------------------------------------------------------+--------|
|Do not give permission. Use as a place holder when setting|- |
|multiple permissions. | |
|----------------------------------------------------------+--------|
|Set to group's current permissions. |g |
|----------------------------------------------------------+--------|
|Set to other's current permissions. |o |
|----------------------------------------------------------+--------|
|Set read permission. |r |
|----------------------------------------------------------+--------|
|Set user or group id . |s |
|----------------------------------------------------------+--------|
|Set sticky. |t |
|----------------------------------------------------------+--------|
|Set to user's current permissions. |u |
|----------------------------------------------------------+--------|
|Set write permission. |w |
|----------------------------------------------------------+--------|
|Set execute permission. |x |
+-------------------------------------------------------------------+
Type: chmod number .
The number is usually three digits. From left to write, the digits stand for the permissions for the user, the group, and other users.
You can calculate the digit to use by adding the octal number for each permission. Calculating Numbers for the chmod Command Absolute Mode, Section 9.19.4.3. You must use at least three digits in Absolute Mode.
A fourth number is sometimes added as a prefix to set user or group id or to set sticky. See The chmod Command (Change Permissions): The 4th Digit in Absolute Mode, Section 9.19.4.5. "The chown Command (Change Permissions): The 4th Digit in Absolute Mode," page 200.
To calculate each digit in Absolute Mode (See The chmod Command (Permissions): Absolute Mode, Section 9.19.4.4), add the octal numbers for the permissions you want to set. For example, the number to set read and execute permission is 5 (4+1).
The first three digits are for the user, group, and others. For example, 754 gives:
The user read, write, and execute permission.
The group read and execute permission.
Others read permission.
You may also use a fourth digit. See The chmod Command (Change Permissions): The 4th Digit in Absolute Mode, Section 9.19.4.5.
+--------------------------------+
| Permission |Octal Number|
|-------------------+------------|
|Read permission. |4 |
|-------------------+------------|
|Write permission. |2 |
|-------------------+------------|
|Execute permission.|1 |
|-------------------+------------|
|No permissions. |0 |
+--------------------------------+
+------------------------+
|Permission |Octal Number|
|-----------+------------|
|User id . |4 |
|-----------+------------|
|Group id . |2 |
|-----------+------------|
|Set sticky.|1 |
+------------------------+
[Note]
The fourth digit in Absolute Mode is optional.
All files include:
A creation time: The date and time that the file was created.
An access time: The date and time that the file was last used.
A modification time: The date and time that the file was last changed.
To change the creation time, use the cp command without the -a or --archive options.
To change the other times, type: touch options file .
The Touch Command (Changing Date Attributes)
+-------------------------------------------------------------------+
| Option | Action | Comments |
|-----------------+--------------------------------+----------------|
| * -a |Changes the access time to the | |
| * --time-access|current time. | |
|-----------------+--------------------------------+----------------|
| * -m |Changes the modification time to| |
| * --time-mtime |the current time. | |
|-----------------+--------------------------------+----------------|
| |Uses the time specified instead |Use the format: |
|-t time |of the current time. | |
| | |ccyymmddhhmm.ss.|
+-------------------------------------------------------------------+
You can set special file attributes on a native Linux (ext2) filesystem. These attributes affect how the file can be edited, deleted, or backed up.
These special attributes are in addition to the usual set of ownership, permissions and dates. They are not automatically assigned to a file.
Type: chattr options actions attributes files .
Do not put a space between the action and attribute argument.
The chattr Command (Change Attributes): Options
+-------------------------------------------------------------------+
|Option| Action |Comments|
|------+---------------------------------------------------+--------|
|-R |Changes attributes of sub-directories and their | |
| |contents. | |
|------+---------------------------------------------------+--------|
|-V |Displays actions on screen. | |
+-------------------------------------------------------------------+
The chattr Command (Change Attributes): Actions
+-------------------------------------------------------------------+
| Action |Argument|
|----------------------------------------------------------+--------|
|Adds the attribute. |+ |
|----------------------------------------------------------+--------|
|Removes the attribute. |- |
|----------------------------------------------------------+--------|
|Sets only the attribute specified. Removes other |= |
|attributes. | |
+-------------------------------------------------------------------+
The chattr Command (Change Attributes): Attributes
+-------------------------------------------------------------------+
| Attribute |Argument|
|----------------------------------------------------------+--------|
|Date and time are not updated when the file is modified. |A |
|----------------------------------------------------------+--------|
|Material can only be added to the end of the file. |a |
|Existing contents cannot be changed. | |
|----------------------------------------------------------+--------|
|File can only be modified by the root user. |i |
|----------------------------------------------------------+--------|
|File cannot be recovered when deleted. |s |
|----------------------------------------------------------+--------|
|File cannot be deleted. |u |
|----------------------------------------------------------+--------|
|Do not include in backup using dump. |d |
+-------------------------------------------------------------------+
Type: lsattr options files .
Files are displayed one line at a time.
Options for the lsattr Command (List Attributes)
+----------------------------------------------------------+
|Option| Action |Comments|
|------+------------------------------------------+--------|
|-a |Shows all files in the directory listed. | |
|------+------------------------------------------+--------|
|-d |Lists directories' attributes, not files'.| |
+----------------------------------------------------------+
[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ A ] [ B ] [ C ] [ D ] [ next ]
User's Guide
Version: 1.00p00, 2008.03.02-20:48