Quick reference guide Scientific Linux for DESY

Previous Contents Index Next 

2. File directory and file system commands

By far the most frequently used commands are ls and cd, therefore some ls and cd related aliases are presented which were found to be useful for the daily work

The options, if mentioned but not described in further detail for the commands chmod, chgrp, chown, cp, ln, mv, and rm do have the meaning:
-f force operation without querying and suppress error messages
-i prompt before an action that deletes or overwrites files
-R recursively operate on directories
-v verbose, show what is being done

cd [directory] S
Change the current directory. Without argument changes to home directory. cd - changes to previous directory.  
chgrp [-Rfv] group file[s]
Change the group ownership of files Documentation
chmod [-Rfv] mode file[s]
Change the access permissions of files. Mode can be an (octal) value where the 3 rightmost digits ugo denote user, group and other's permissions and the bits in the digit stand for read (4), write (2) and execute (1) permission. Documentation
Example: 710 sets all permissions for the owner and execute for group.
Mode can also be a string of letters (ugoa for user, group, others or all) followed by an operator +-= to add, take away or assign permissions followed by the permissions rwx for read, write and execute.
Example: g+w adds group write permissions to the file[s].
Beware: on AFS file systems only the user permissions are respected. For setting access rights in AFS see fs.
Documentation
chown [-Rfv] [user][:group] file[s]
Change the user (and group) ownership of files. Documentation
cp [-Rfipuv] source destination
cp [-Rfipuv] source[s] directory  
Copy files. With -p preserve owner, group and time stamps in the copied file[s]. -u copies only newer or missing source files Documentation
cp -a [-fiulsLx] sourcedir targetdir
Copy files recursively, i.e. a whole directory tree. -a is equivalent to -dpR. Look up the meaning of -l, -s, -L and -x for influencing the copy process. Documentation
cpd AZ
Change to a directory previously visited.  
df [-k] [file[s]]
Displays free disk space in blocks (-k in kbytes) of all mounted file systems or of the file systems where file[s] are found. For AFS see fs. Documentation
du [-ks] [dir[s]]
Summarize disk usage in units of disk blocks (-k in kbytes). With -s display only the grand total, otherwise report recursively on each directory. Documentation
groups [username[s]]
Print the groups a user is in Documentation
id [-gGnru] [username]
Print real (-r) and effective user (-u) and group (-gG) IDs or names (-n) for the current user or username. Prints all the information if no options given. Documentation
ll [option[s]] [file[s]] A
Shorthand for ls -l. Additional options as for ls can be given.  
ln [-fisv] file new_name
ln [-fisv] dir[s] new_directory_name  
Make links between files. Hard links can be established within a file system only (not within AFS). Symlinks (with -s) are more flexible and visible. Documentation
ls [-abcdFlLnrRStu] [file[s]] A
List contents of directories. The most frequently used options are
-a list all entries, including those starting with a dot (.)
-b print octal escapes for nongraphic characters
-c use time of last inode modification (with -l, -n and -t)
-d if the argument is a directory, list only its name, not its contents
-F append /, * and @ to filename for dirs, executables and symlinks resp.
-l list in long format (mode, number of links, owner, group, size, time)
-L if the argument is a symbolic link, list the file it is pointing to
-n like -l, but display UID and GID instead of owner and group
-r reverse order of sort (alphabetic or by time)
-R recursively list subdirectories
-S sort by file size
-t sort by time instead of by name (default: last file modification time)
-u use time of last access (with -l, -n and -t)
ls is usually aliased to ls --color=tty to distinguish file types by color. The alias (like all aliases) gets suppressed by prefixing it with backslash: \ls
Documentation
lsize [directory] AZ
List the 20 largest files in a directory. This is similar to ls -lS.  
lt [option[s]] [file[s]] A
List contents of directories by file modification time (long form). Similar to ls -lt. Additional options as for ls can be given. Only the 20 newest files are printed. Useful also in conjunction with options -r (display the oldest files), -u (sort by access time) and -c (sort by inode modification time).  
mkdir [-p] [-m mode] dir[s]
Make directories. With -p a directory hierarchy can be created. The permission mode can be set simultaneously Documentation
mv [-fiv] source destination
mv [-fiv] source[s] directory  
Rename source file to destination file or move source files[s] into directory. Documentation
newgrp [group]
Change group ID to group or back to group in passwd entry if no group is given. Each call of newgrp opens a new shell like login does.  
pwd S
Print name of current/working directory Documentation
quota [-v] [username] MZ
Display disk usage and limits. Hamburg: Does not work for AFS, please see fs listquota.
Zeuthen: System command replaced by a script to report quota on all AFS volumes belonging to the current user or username, not only on home dir.
To identify files for removal the commands
du, lsize, lt -r, lt -ru, find and locate are useful.
 
rm [-fiv] file[s]
rm -rR [-fiv] dir[s]  
Remove files (or for -r or -R whole directory trees). Documentation
rmdir [-p] dir[s]
Remove empty directories (and with -p its empty parent dirs as well) Documentation
rsync [-ah] source destination
Fast remote file copy. Option -h outputs usage information. Allows to synchronize remote and local directories. Uses ssh by default. The arguments are of the form [[user@]host:]filename. The most useful option -a allows to recursively copy directories by preserving inode information (syncing dirs). Example: rsync -av user@remote_host:remote_dir local_dir  
scp [-pr] source destination
Secure remote file copy. With -p preserve owner, group and time stamps in the copied file[s]. The arguments are of the form [[user@]host:]filename.  
stat [-f] [-Z] file[s]
Display attributes of files, with option -f of file systems. Prints with -Z also security context information if available. Documentation
touch [-r ref_file] [-t [[CC]YY]MMDDhhmm[.ss]] file[s]
Change file access and modification times. Used to create empty files. Timestamps can be set (-t) or copied from ref_file (-r). Documentation
umask [mask] S
Get or set file-creation mode mask. The files get created with permissions 0777 - mask (dirs and executables) or 0666 - mask for other files (usually mask = 022 ). See chmod for the meaning of the mode bits in mask.  

Previous Contents Index Next