File commands

From LQWiki
Jump to: navigation, search

File Commands

File Search

  • find - Versatile tool for searching for files based on name, size, date, etc.
  • locate - Lists all files with a given word in the name
  • whereis - Finds commands, source, and manpages
  • which - Finds commands on the path
  • grep - Searches for text/patterns within a file

File Analysis

  • cksum - Calculate the checksum of a file.
  • diff - Find differences between two files.
  • file - Determine file type.
  • ls - List the contents of a directory.
  • lsattr - List the attributes of a file.
  • md5sum - Calculate or check the MD5 checksum of a file
  • wc - Displays line, word and character count for specified filename.

File Manipulation

  • cp - Copy a file from one location to another.
  • dd - Copies a file and performs various conversions at the same time.
  • some dd examples - This is good stuff. Must read for anyone serious about Linux
  • du - Shows disk usage of files
  • install - Copy file(s), preserving permissions.
  • ln - Create a link to a file.
  • mv - Rename or move a file.
  • rename - Another renaming tool
  • rm - Remove (delete) a file.

File Attribute Manipulation

  • chgrp - Change the group ownership of a file or directory.
  • chmod - Change the mode (access permissions) of a file or directory.
  • chown - Change the ownership of a file or directory.
  • getfacl - View the acl permissions associated with the file or directory.
  • setfacl - Change the acl permissions associated with the file or directory.
  • touch - Update access times or, potentially, create a file.

File usage

  • lsof - List all currently opened files
  • fuser - List which processes that are currently using a specific file