Linux Commands: Files and Directories¶
Create, copy, move, find, archive and verify files, and manage permissions and ownership.
Part of the Linux commands cheat sheet.
File Operations Commands¶
access — Check read, write, and execute permissions:
basename — Strip directory and suffix from filenames:
cat — Concatenate files and print on the standard output:
cksum — Print CRC checksum and byte count:
cmp — Compare two files byte by byte:
compress — Compress data into .Z format:
cp — Copy files and directories:
cpio — Copy files to and from archives:
csplit — Split a file into context-determined pieces:
cut — Remove sections from each line of files:
diff — Find differences between two files:
diff3 — Compare three files line by line:
echo — Display a line of text:
expand — Convert tabs to spaces:
file — Determine file type:
fold — Wrap each input line to fit in specified width:
head — Output the first part of files:
join — Join lines of two files on a common field:
less — View file contents interactively (allows backward movement):
ln — Make links between files (hard or symbolic):
locate — Find files by name using a database:
look — Display lines beginning with a given string:
more — File perusal filter for viewing one screen at a time:
mv — Move or rename files and directories:
od — Dump files in octal and other formats:
paste — Merge lines of files side-by-side:
readlink — Print resolved symbolic link or canonical file name:
rename — Rename multiple files using regular expressions:
rev — Reverse the order of characters in every line:
rm — Remove files or directories:
shred — Overwrite a file to hide its contents, and optionally delete it:
sort — Sort lines of text files:
split — Split a file into pieces:
tac — Concatenate and print files in reverse order (last line first):
tail — Output the last part of files:
tar — Store and extract files from an archive:
tee — Read from standard input and write to standard output and files:
touch — Change file timestamps or create an empty file:
unexpand — Convert spaces to tabs:
uniq — Report or omit repeated lines:
wc — Print newline, word, and byte counts for each file:
Directory Operations Commands¶
cd — Change the shell working directory:
dir — List directory contents (similar to ls):
dirname — Strip non-directory suffix from file name:
dirs — Display list of currently remembered directories:
du — Estimate file and directory space usage:
find — Search for files in a directory hierarchy:
lsblk — List information about block devices:
mkdir — Make directories:
mount — Mount a filesystem:
pwd — Print name of current/working directory:
rmdir — Remove empty directories:
tree — List contents of directories in a tree-like format:
File Permission and Ownership Commands¶
chmod — Change file mode bits (permissions):
chattr — Change file attributes on a Linux file system:
chown — Change file owner and group:
chgrp — Change group ownership:
Compression and Archiving Commands¶
ar — Create, modify, and extract from archives:
bzcmp — Compare bzip2 compressed files:
bzdiff — Compare bzip2 compressed files:
bzgrep — Search bzip2 compressed files for a regular expression:
bzip2 — A block-sorting file compressor:
bzless — File perusal filter for crt viewing of bzip2 compressed text:
bzmore — File perusal filter for crt viewing of bzip2 compressed text:
gunzip — Compress or expand files:
gzip — Compress or expand files:
gzexe — Compress executable files in place:
zip — Package and compress files:
zdiff — Compare compressed files:
zgrep — Search possibly compressed files for a regular expression:
Checksum and File Integrity Commands¶
md5sum — Compute and check MD5 message digest:
cksum — Print CRC checksum and byte counts:
sum — Checksum and count the blocks in a file: