BSD / Linux - Some UNIX FILE & DIRECTORY Commands

8/14/99
  • RENAME A FILE USE mv (Move a File)
  • LIST FILE CONTENTS
    more <name1> displays the contents of file <name1> on the screen, one page at a time (press the space bar to see any additional pages - type 'q' to quit).
    less &lf;name1> - same as more except you can page up as well as down. The "b" key backs up one page. AR
    CAT
    CD - Change Directory
    CHKDUPEXE - Find Duplicate Executables
    CHATTR
    CHFLAGS- Change
    CHGRP- Change
    CHMOD - Change the Access Permissions of Files
    CHOWN- Change
    CJPEG - Compress an image file to a JPEG file
    CKSUM - Checksum and Count the Bytes in a File
    CMP - Compare Two Files of Any Type
    COMM
    COMPRESS
    CP - Copy A File
    CUT
    DC
    DIFF - Find Differences Between Two Files
    DIFF3 - Find Differences Between Three Files
    DJPEG - Decompress a JPEG File to an Image File
    DSPLIT - Split a Large File into Pieces
    FILE
    FIND - Find a File
    FIZ - Analyze a Damaged ZOO Archive for Data Recovery
    FUSER
    GZIP
    HEAD
    LOCATE
    LOOK
    LS - List File Names
      MKDIR - Create a Directory
    MV - Move a File
    PASTE
      PWD - Display the Name of the Current/Working Directory
    RDJPGCOM - Display Text Comments from a JPEG File
    REV
      RM - Delete/Erase a File
      RMDIR - Remove an Empty Directory
    SORT
    SPLIT - Split a File Into Pieces
    SUM
    TAIL
      TAR - Tape ARchiver; manipulate "tar" archive files
      TOUCH - Change a File's Timestamps
    ZIP
    ZOO

    DIRECTORIES
    CD - Change Directory - NOTE: you must have a space after cd , unlike in DOS.
    cd <directory name> Change to directory whose name is <directory name>, assuming that the named directory is within the current directory or that you provide the entire pathname of the directory.
    cd Change to the home directory.
    cd .. move up one directory level.
      MKDIR - Create a Directory
    mkdir dddd.dd.dd will create the directory dddd.dd.dd in the current directory.
      RMDIR - Remove an Empty Directory
    rmdir dddd.dd.dd will remove the directory dddd.dd.dd if it exists in the current directory and is empty. (see rm -ir dddd.dd.dd to remove the directory and everything in it)
      PWD - Display the Name of the Current/Working Directory
    If you are in /etc/skel,
    pwd will display /etc/skel - what is displayed is the actual directory name (fully resolved), not a symbolic link

    FILE ATTRIBUTES
    Each file has an assigned set of mode bits, ownership (user and group), and flags. To view these assignments, run the command ls -lo and get a result like this (only one file is shown)
    -rw-r--r-- 1 root wheel sappnd,arch 2188 Sep 17 2003 junk.test

    The first grouping of characters represent the modes assigned to the file.
    root is the file's owner
    wheel is the file's group
    sappnd,arch are the file's flags

      chmod changes the file's mode
      chown changes the file's owner
      chgrp changes the file's group
      chflags changes the file's flags

    AR
    CAT
    CHKDUPEXE - Find Duplicate Executables
    CHATTR


  • CKSUM - Checksum and Count the Bytes in a File
    cksum fffff displays the checksum, size (in bytes) and the file name of file fffff
    for example, cksum vmlinuz displays 1266362081 461067 vmlinuz
    CMP - Compare Two Files of Any Type

  • CP - Copy a File
    cp <source file> <target file> Copies source file to target file of the same or another subdirectory and names it <target file>
    cp <source file> <target directory> Copies source file to another file of the same name in the subdirectory of <target directory>
    cp ~user_name/file . Ccopies file from the main directory of the user, user_name, to the directory in which you are crrently located.
    cp -r <source directory> <target directory> Copies <source directory >, and everything in it, to <target directory>
    -b Make backups of files that are about to be overwritten or removed. (add ~ to end of file name)
    -i Interactive - asks whether to overwrite each existing destination file
    -v Verbose - shows the name of each file before copying it


    COMM
    COMPRESS
    CUT
    DC
    DIFF - Find Differences Between Two Files
    DIFF3 - Find Differences Between Three Files
    FILE

    FIND - Find a File
    find <start dir> -name <pattern> find / -name gz* will locate all files starting in the root directory with a name matching "gz*". NOTE: THIS WILL ALSO SEARCH ALL ATTACHED DISKS INCLUDING CD-ROMs IF MOUNTED - Try to start with a lower level directory. (the -mount switch will also prevent this)
    find / -mtime -1 \! -type d will list all files (starting with the root directory) changed in the last 24 hours. /mtime -1 specifies the 24 hour filter. \! -type d excludes directories from file list.
    find / -xdev -name X*.h finds all files matching X*.h (* is a wildcard). the -xdev switch excludes any other type of file systems from being searched (the root is an ext2 system, /dosc is a dos system).

    FUSER
    GZIP
    HEAD
    LOCATE
    LOOK

  • LS - List File Names
    ls Provides a list of files and directories in the current subdirectory
    ls -a Includes 'hidden' files in this list (to 'hide' a file, just use the period (.) as the first character of the file name)
    ls -l l = long - includes file sizes and ownerships in this list
    ls <dirname> Llist files and directories within the directory <dirname>, assuming the directory <dirname> is within the current directory, otherwise you must specify the directory's complete pathname
    ls | less allows you to page through a long list of files ('q' quits the paging)


  • MV - Move A File
    mv <source name> <directory name> If <directory name> exists, move file or directory <source name> into directory <directory name>
    mv <source file name> <target file name> Similar to copy except that the source file is deleted. Note that the name may be changed during the move
    -b Make backups of files that are about to be removed (add ~ to end file file name)
    -i Interactive mode - asks whether to overwrite a destination file that already exists.
    -v Verbose - Show the name of each file before moving it
    Note: This command will not work on another persons account!!

    PASTE
    REV

      RM - Delete/Erase a File
    rm -i <filename> Removes the file whose name is <filename>
    rm * Removes all files in the current subdirectory
    rm -ir <dirname> Removes a directory and everything in it. DO NOT OMIT THE 'i'(interactive option) or you may lose more than you want

    SORT
    DSPLIT - Split a Large File into Pieces
    SPLIT - Split a File Into Pieces
    SUM
    TAIL
      TAR - Tape ARchiver; manipulate "tar" archive files

      TOUCH - Change a File's timestamps
    touch demo1.cpp updates the access and modification times of demo1.cpp to the current time
    Options include :
    -a - Changes only the access time.
    -m - Changes only the modification time.

    ZIP
    FIZ - Analyze a Damaged ZOO Archive for Data Recovery
    ZOO
  • CJPEG - Compress an image file to a JPEG file
    DJPEG - Decompress a JPEG File to an Image File
    RDJPGCOM - Display Text Comments from a JPEG File

    Back to the LINUX home page...