1 | 2 | 3 | 4 | 5 | 6 | page 7 | 8 | 9 | 10 | 11
Command Description
cp Copy a source file to a target file.
  • cp file1 file2 copy contents of file1 into file2, overwriting file2 if it exists.

  • cp -i file1 file2 copy and prompt for overriding if file2 exists, answer yes or no to the prompt to override or not.

  • cp filename ../ copy a file to its parent directory.

  • cp *.jpg ~ copy all files with extension .jpg to the login directory.

  • cp * /directory copy all files (no directories) to a specified directory.

  • cp -r /dir1 /dir2 copy directory dir1 and all its files and subdirectories to be a new subdirectory of dir2.
  • df Reports on used disk space on the partition containing file. Use the option -h to see a summary of used and available disk space. This command shows how various partitions of your server file system are allocated and their physical location on the server hard disks. For example,
    [brucelee@ ~]$ df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda3 108G 43G 61G 42% /
    /dev/sda1 99M 17M 77M 19% /boot
    tmpfs 505M 0 505M 0% /dev/shm
    file Determine file type of filename. For example,
    [brucelee@ ~]$ file 15589.txt
    15589.txt: ASCII text

    Command Description
    find Find files in the file system hierarchy. For example, the following file is found in the subdirectory name img/ from the current directory.
    [brucelee@ ~]$ find -name "4.txt"

    An action can be specified as parameters of the find command. For example, search and delete files beginning with 195 starting from the current directory.
    [brucelee@ ~]$ find -name 195\*
    find: ./gconfd-root: Permission denied
    [brucelee@ ~]$ find -name 195\* -delete

    If you don't run this command as root, find will display an error message for each directory on which you do not have proper read access.

    Any Linux commands can be applied to the results found by find. You can develop scripts using this feature to automate your administrative tasks. The following example shows the file size of files beginning with 38.
    [brucelee@ ~]$ find -name 38.\* -exec ls -l {} \;
    -rw-r--r-- 1 ldao ldao 26508 2008-11-10 08:06 ./38.us.jpg

    Typical usage of find
    Find empty directories
    find -depth -type d -empty
    Find empty files
    find -depth -type f -empty
    Find a file with a specific name
    find -name name-of-file
    Find a file with a specific extension
    find -name "*.extension"
    Find files with specific permissions
    find -perm 644
    Find files of give sizes
    find -size 63k (find -help for details)
    Find files modified within a specified time frame
    find -mtime 0
    Find orphan files and directories.
    find -nouser
    1 | 2 | 3 | 4 | 5 | 6 | page 7 | 8 | 9 | 10 | 11