4. Files and Directories

  • extension is not needed

  • .myfile - hidden, if name starts with dot

  • .mydirectory/ - hidden, if name starts with dot

  • / - root dir

  • . - current dir

  • .. - upper dir

4.1. Change Directory

  • cd

  • cd /absolute/path

  • cd relative/path

  • cd ~

  • cd -

  • cd ..

4.2. List Files and Directories

  • ls

  • ls /absolute/path

  • ls relative/path

  • ls -lah

  • alias l='ls -lAh --color=auto'

4.3. Files

Table 4.1. Files

Command

Type

Description

sum

checksum and count the blocks in a file

vi

Vi IMproved, a programmer's text editor

vim

Vi IMproved, a programmer's text editor

vimdiff

edit between two and eight versions of a file with Vim and show differences

wc -c

print number of characters in file

wc -l

print number of lines in file

wc

print newline, word, and byte counts for each file

egrep

print lines that match patterns

cut

remove sections from each line of files

head

output the first part of files

hexdump

display file contents in hexadecimal, decimal, octal, or ascii

grep

print lines that match patterns

join

join lines of two files on a common field

diff

compare files line by line

split

split a file into pieces

view

Vi IMproved, a programmer's text editor

strings

print the sequences of printable characters in files

write

write to a file descriptor

uniq

report or omit repeated lines

sort

sort lines of text files

pico

Nano's ANOther editor, inspired by Pico

open

open and possibly create a file

read

read from a file descriptor

puts

output of characters and strings

readline

(3readline)

get a line from a user with editing

cat

concatenate files and print on the standard output

dd

convert and copy a file

ed

line-oriented text editor

edit

encguess

guess character encodings of files

file

determine file type

file

overview of system data types

more

file perusal filter for crt viewing

nano

Nano's ANOther editor, inspired by Pico

setcap

set file capabilities

tail -f

tail

output the last part of files

tailf

tee

read from standard input and write to standard output and files

tee

duplicating pipe content

tempfile

create a temporary file in a safe manner

unlink

call the unlink function to remove the specified file

unlink

delete a name and possibly the file it refers to

patch

apply a diff file to an original

4.4. Directories

Table 4.2. Directories

Command

Type

Description

chroot

change root directory

chroot

run command or interactive shell with special root directory

mkdir

make directories

mkdir

create a directory

rmdir

remove empty directories

rmdir

delete a directory

4.5. Files and Directories

Table 4.3. Files and Directories

Command

Type

Description

mc

Midnight Commander

cd

Change directory

chattr

change file attributes on a Linux file system

chgrp

change group ownership

chmod

change file mode bits

chmod

change permissions of a file

chown

change file owner and group

chown

change ownership of a file

cp

copy files and directories

cpio

copy files to and from archives

dir

list directory contents

dirname

strip last component from file name

dirname

parse pathname components

du -hs

du

estimate file space usage

find

search for files in a directory hierarchy

l

la

less

opposite of more

ll

ln -s

ln

make links between files

locate

Locates file (from updatedb database)

ls

list directory contents

lsattr

list file attributes on a Linux second extended file system

mv

move (rename) files

pwd

print name of current/working directory

rcp

OpenSSH secure file copy

rm -fr

rm

Remove

rm

remove files or directories

rsync

Syncronizes two directories

rsync

a fast, versatile, remote (and local) file-copying tool

scp

OpenSSH secure file copy

shred

overwrite a file to hide its contents, and optionally delete it

size

list section sizes and total size of binary files

stat

display file or file system status

touch

change file timestamps

tree

list contents of directories in a tree-like format.

umask

set file mode creation mask

updatedb

Scans filesystem and create database for locate