Hard disk,Archive And Unarchive Commands in debian
Hadisk Commands in Debian
If you want to check the your hard disk space used,free in your machine use the following commands
du - Disk Space Used
prints a summary of the amount of information you have stored in your directories on the mounted disks.
Syntax
du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories
Options
-a
|
Displays the space that each file is taking up.
|
-k
|
Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.
|
-s
|
Instead of the default output, report only the total sum for each of the specified files.
|
-d
|
Do not cross filesystem boundaries. For example, du -d / reports usage only on the root partition.
|
-L
|
Process symbolic links by using the file or directory which the symbolic link references, rather than the link itself.
|
-o
|
Do not add child directories' usage to a parent's total. Without this option, the usage listed for a particular directory is the space taken by the files in that directory, as well as the files in all directories beneath it. This option does nothing if -s is used.
|
-r
|
Generate messages about directories that cannot be read, files that cannot be opened, and so forth, rather than being silent (the default).
|
-x
|
When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand.
|
directories
|
Specifies the directory or directorie
|
df - Disk Space Free
Tells you how much free disk space is available for each mount you have.
Syntax
df [ -F FSType ] [-a [-b] [-e] [-g] [-k] [-l] [-n] [-t] [-V ] [ -o FSTypespecific_options ] [block_device | directory | file | resource ... ] [-P]
Options
-F FSType
|
Specify the FSType on which to operate. The -F option is intended for use with unmounted file systems. The FSType should be specified here or be determinable from /etc/vfstab (see vfstab(4)) have the by matching the directory, block_device, or resource with an entry in the table, or by con-
sulting /etc/default/fs. See default_fs(4).
|
-a
|
Report on all file systems including ones whose entries in /etc/mnttab (see mnttab(4)) have the ignore option set.
|
-b
|
Displays the disk space free in kilobytes.
|
-e
|
Print only the number of files free.
|
-g
|
Print the entire statvfs(2) structure. This option is used only for mounted file systems. It cannot be used with the -o option. This option overrides the -b, -e, -k, -n, -P, and -t options.
|
-k
|
Print the allocation in kbytes. The output consists of one line of information for each specified file system. This information includes the file system name, the total space allocated in the file system, the amount of space allocated to
existing files, the total amount of space available for the creation of new files by unpriviledged users, and the percentage of normally available space that is currently allocated to all files on the file system. This option overrides the -b, -e, -n, and -t options.
|
-l
|
Report on local file systems only. This option is used only for mounted file systems. It cannot be used with the -o option.
|
-n
|
Print only the FSType name. Invoked with no operands, this option prints a list of mounted file system types. This option is used only for mounted file systems. It cannot be used with the -o option.
|
-t
|
Print full listings with totals. This option over rides the -b, -e, and -n options.
|
-V
|
Echo the complete set of file system specific command lines, but do not execute them. The command line is generated by using the options and operands provided by the user and adding to them information derived from /etc/mnttab, /etc/vfstab, or /etc/default/fs. This option may be used to verify and validate the command line.
|
- o FSTypespecific_options
|
Specify FSType-specific options. These options are comma-separated, with no intervening spaces.
|
block_device
|
represents a block special device (for example, /dev/dsk/c1d0s7); the corresponding file system need not be mounted.
|
directory
|
represents a valid directory name. df reports on the file system that contains directory.
|
file
|
represents a valid file name. df reports on the file system that contains file.
|
resourece
|
represents an NFS resource name.
|
-P
|
Same as -k except in 512-byte units.
|
Checking or Repairing a File System
The native Linux filesystem (ext2) does not need to be defragmented. However, occasionally, you may need to check a partition's file allocation and make repairs.
Type: fsck options filesystem or fsck options mountpoint .
Note that:
- By default, repairs are done without prompting.
- Two ways of specifying a filesystem exist. You do not need to specify a filesystem if you use the -t or -A options.
- This check is also run when the system starts if it was not shut down gracefully or after a predefined number or reboots.
Options
-A Checks all filesystems listed in /etc/fstab.
-r Prompts before each repairs is done.
-R Checks all filesystems listed in /etc/fstab except the root partition.
-t To only check filesystems of a certain type
Archive and Unarchive Commands in Debian
Archiving
The basic command for archiving files with the tar command is:
tar -cvf archive_name file1 file2
where:
c - needed for creating a new file.
v - option for displaying the name of each file being archived.
f - needed for using the next argument as the name for the archive.
file1, file2, ... are the names of files that are being archived.
Suppose, you wish to archive the files: "freq.sas", "plot.sas" and "sort.sas", and you wish to create an archive file called "sasfiles.tar". In this case, the tar command will be:
tar -cvf testfiles.tar resa plot sort
The basic command for archiving directories with the tar command is:
tar -cvf archive_name -C directory
where:
C - performs a chdir subroutine,
directory - is the name of the subdirectory that is being archived, and it may be a parent to one more directories.
Suppose, you wish to archive the subdirectory "sasdir" which are in your home directory, and you wish to create an archive file called "sasdir.tar". In this case, the tar command when executed in your home directory will be:
tar -cvf testdir.tar -C testdir
Suppose, you wish to archive the subdirectories "sasdir" and "spssdir" both of which are in your home directory. In this case the tar command executed in your home directory will be:
tar -cvf testdir.tar -C testdir . -C ../testdir
What to do with .tar.gz files?
Whenever you want to download something from the internet for your computer, it always seems to be in .tar.gz format. The problem is, you can never remember how to decompress these files. So here's how: type
tar -xvpzf file.tar.gz
The meanings of the options are:
x Extract the file(s).
v Be verbose (print out file names as they're extracted).
p Keep permissions
z Filter it through the "gzip" unzipping program.
f Do the extracting from the given file.
You've also discovered a lot of files in .tar.bz2 format. In that case you use "I" instead of "z", so that it filters through bzip2 instead of gzip.
Unarchiving
The tar command can also be used for unarchiving a tar file, but before unarchiving, there are a couple of things that you need to do to avoid any problems.
- Use the "fs listquota" command to check whether you have sufficient AFS file space. If space is insufficient then copy the tar file to the system temporary storage area such as "/save".
- Always move to an empty directory before unarchiving a tar file. This is necessary because when you unarchive a tar file, its contents will overwrite files or directories with same names that are in the current directory. You can use the UNIX "mkdir" command to create an empty directory.
The basic command to unarchive a tar file is:
tar -xvf filename.tar
This will unarchive the contents of the tar file "filename.tar" to the current directory.
For more information on the tar command, please enter "man tar" at the system prompt.
Compressing and decompressing Files With the gzip Command
The gzip command is one of the two Linux tools for compressing and decompressing files. The other is bzip2 . The bzip2 command can compress files more, but gzip is more common, and can sometimes read zipped files, or compressed files created with the obsolete tool compress .
A file compressed using gzip has a .gz extension.
Type: gzip options files .
Separate file names with a space.
The gzip command has several related utilities:
- zcat : Displays files in a gzip archive.
- zcmp : Compares files in a gzip archive.
- zdiff : Compares files in a gzip archive.
- zgrep, zegrep, zfgrep : Search for text patterns in files in a gzip archive.
- gunzip : decompresses files. However, gzip -d also decompresses.
All these commands have the same format as gzip . They can use the same options as the versions of the commands used for uncompressed files.
For more Options click here
Compressing and decompressing With the bzip2 Command
The bzip2 command is one of two tools for compressing and decompressing files. The other is gzip . The gzip command is more common, but bzip2 's compression is 10 to 20 percent greater, depending on the file.
Compressed files made with bzip2 have a .bz2 extension.
Type: bzip2 options files .
Separate each name with a space.
The bzip2 command has three related utilities:
- bzipcat : Displays the contents of a file in a bzip compressed file. Uses the same options as the cat command.
- bziprecover : Helps to recover damaged compressed files.
- bunzip2 : decompresses files. However, many users prefer bzip2 -d for decompressing files.
For more options click here