tail

outputs the last (by default 10) lines of the specified file to stdout.

tail /var/log/syslog

show the last 10 lines of syslog;

tail -22 /var/log/httpd/access.log

show the last 22 lines of access.log (Apache web-server);

tail -f /var/log/messages

output the last appended lines continuously;

dmesg | tail -20

show the last 20 lines of dmesg (kernel ring buffer);

tail [options] [file] ...

Options

--help    --version    -v    --verbose

-c n, --bytes=n

print the last n bytes of a file;

-f, --follow

continuously output the appended data as file grows; note that if the name of the file is changed while ~ is running, the data will be taken from the old file, because ~ follows descriptor, not filename;

-n m, --lines=m

print the last m lines;

-q, --quiet, --silent

never print headers giving file names;

-s n, --sleep-interval=n

(with -f, --follow= fname) sleep approximately n sec between iterations (default is 1 sec);

--follow= fname

like -f, but ~ follows the explicitly specified filename, not file descriptor (it has sense in case of log rotation);

--max-unchanged-stats=n

(with --follow=fname) reopen a file which has not changed size after n (default is 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files);

--pid=n

(with -f, --follow= fname) terminate after the process with the specified ID has finished;

--retry

(with -f, --follow= fname) keep trying to open a file even if it is inaccessible when ~ starts, or if it becomes inaccessible later;

tar

is an archiving program. Its original purpose was to work with tape archives, hence the name. ~ is often used in combination with compressors like gzip or bzip2 to create .tar.gz, .tgz, .tar.bz2 archive files. Though the above extensions are not mandatory, you should use them to avoid chaos. For non-compressed archives use .tar.

tar cmd [options] -f arc [target]

arc is the name of an archive file or the name of a device where archive should be created or from where it must be extracted, target specifies files or dirs to be archived.

tar tvf notes.tar

list contents of the archive notes.tar;

tar -cvf ../notes.tar .

join all files (including subdirs) in the current dir into one big file notes.tar and save it one level above (in the parent dir);

tar -xvf notes.tar

unpack notes.tar in the current dir (may be you should clean it before running this cmd); the src file (archive) stays as is;

tar -cvf notes.tar ./notes

join all files (including subdirs) in the subdir notes into one big file notes.tar and save it in the current dir; note that you can unpack this archive using prev cmd, but the result will be a little bit different: first, subdir notes will be created (provided it does not exist), then archive contents will be written into that subdir;

tar ztvf info4.tar.gz

list contents of the compressed archive info4.tar.gz;

tar zxvf info4.tar.gz

extract all files from the archive info4.tar.gz; word "extract" has no special meaning in this case, you can also say "unpack"; the src file (archive) is not changed;

tar jxvf info5.tar.bz2

extract all files from the archive info5.tar.bz2;

tar -zxvf exp01.tar.gz ./export.log

extract only one specified file (export.log) from the archive exp01.tar.gz;

tar -jxvf /var/inst/exp01.tar.bz2 ./export.log

extract the specified file (export.log) from exp01.tar.bz2 (the archive is in /var/inst/ dir, export.log will be saved in the current dir);

tar -zcvf ../proj1.tar.gz .

archive and compress all files (and dirs) in the current dir (default compression level = 6); arc file proj1.tar.gz will be created in the parent dir; note that you should move to the dir you're want to archive, and run this cmd;

tar -zcvf proj1.tar.gz ./proj1

archive and compress everything in the proj1 subdir; arc file proj1.tar.gz will be created in the current dir; this is similar to the prev cmd, but you should move to the parent dir of the target (the dir we want to archive) and run this cmd; note that this cmd (and prev) preserve dir structure;

tar -jcvf proj1.tar.bz2 proj1/

archive and compress all files and dirs in proj1 dir; this is like prev, but compression is performed by bzip2;

tar cvf /dev/st0 ./arc

archive all contents of arc dir to a SCSI tape device;

Commands

-A, --catenate, --concatenate

append files to archive;

-c, --create

create a new archive;

-d, --diff, --compare

find diffs between archive and fs;

-r, --append

append files to the end of archive;

-t, --list

list contents of archive;

-u, --update

only append files that are newer;

-x, --extract, --get

extract files from archive;

--delete

delete files from archive (not for tapes);

Options

-?    --help    --version    -v    --verbose

--atime-preserve

don't change access time on dumped files;

-C dir, --directory dir

change to dir before doing anything;

-b n, --block-size=n

set block size to n*512 bytes; by default n = 20, that is 10Kb;

--exclude expr

exclude files matching the specified name pattern;

-f arc, --file arc

use the specified archive file or device;

-F script, --info-script script

run script at the end of each tape; implies -M;

-G create/extract/list old GNU-format incremental backup;
-g create/extract/list new GNU-format incremental backup;

-h, --dereference

dereference symlinks, i.e., do not dump symlinks, dump files they point to;

--ignore-failed-read

do not exit with non-zero status on unreadable files;

-i, --ignore-zeros

ignore blocks of zeros in archive (this usually means end of file);

-j, --bzip

filter archive through bzip2;

-k, --keep-old-files

keep existing files, do not overwrite them with archived copies when extracting;

-L n, --tape-length n

set tape length to n*1024 bytes;

-m do not extract file modification time;
-M create/extract/list multi-volume archive;

-N date, --newer date

only store files newer than date;

--numeric-owner

always use numbers for user/group names;

-p extract with original permissions;

-P, --absolute-paths

preserve absolute paths, don't remove leading '/' from file names;

--remove

remove files after adding them to archive;

--same-owner

create extracted files with original ownership;

-S, --sparse

handle sparse files efficiently;

-V name, --label name

create archive with volume name name;

-W, --verfy

attempt to verify archive after writing it;

-X file, --exclude-from file

exclude files listed in file;

-z, --gzip

filter archive through gzip;

tee

reads from stdin and writes to stdout and to a file (i.e., displays on the screen, and simultaneously writes to a specified file).

ps ax | tee proc.txt | more

output the list of the currently running processes and at the same time write the output to the file proc.txt;

tee [options] [file] ...

Options

--help    --version

-a, --append

append to the specified file, do not overwrite it;

-i, --ignore-interrupts

ignore interrupt signals;

time

is an application profiler, it provides timing stats for the specified cmd (elapsed real time between invocation and termination, user cpu time, system cpu time). GNU version also provides info on other resources (mem, i/o, ipc calls).

time [options] cmd [args ...]

Exit status is usually the exit status of the cmd invoked; 126 means cmd could not be invoked, 127 means cmd could not be found.

time ls -Al | wc -l

show time statistics for the specified cmd (ls -Al...) using default output format;

time dd if=/dev/zero of=/tmp/empty.dat
bs=1024K count=256

estimate disk / filesystem write speed;

time -f "\tKernel: %S\tUser: %U\tWaits: %w"
tar ztvf arc2.tar.gz

show stats for the specified cmd (tar ...), in the specified format (kernel/user cpu times, number of context switches due to I/O waits);

Options

--help    -V    --version    -v    --verbose

-a, --append

(used with -o) do not overwrite, append;

-f frmt, --format=frmt

specifies the output format;

-o file, --output=file

save results to the specified file instead of stderr (which is default); overwrite, if such file exists;

-p, --portability

use the portable output format;

The format string interpretation resembles printf: newlines, tabs, backslashes are specified as \n, \t, \\, percent as %% (otherwise it means conversion), ordinary chars are directly copied.

Time format specifications
%E elapsed real time ([hh]:mm:ss);
%e elapsed real time in seconds;
%S total num of cpu seconds the process spent in kernel mode;
%U total num of cpu seconds the process spent in user mode;
%P percentage of cpu usage counted as (%U + %S) / %E;
Memory format specifications
%M max resident set size of the proc during its lifetime (Kbytes);
%t average resident set size of the process (Kbytes);
%K average total (data+stack+text) of the process (Kbytes);
%D average size of the process’s unshared data area (Kbytes);
%p average size of the process’s unshared stack space (Kbytes);
%X average size of the process’s shared text space (Kbytes);
%Z system’s page size (bytes);
%F number of major page faults (page has to be read from disk) that occurred while the process was running;
%R number of minor (recoverable) page faults (page data is still valid, but the system tables must be updated);
%W number of times the process was swapped out of memory;
%c number of times the process was context-switched involuntarily, because the time slice expired;
%w number of times the process was context-switched voluntarily (for example, waiting for i/o to comlete);
I/O format specifications
%I number of file system inputs by the process;
%O number of file system outputs by the process;
%r number of socket messages received by the process;
%s number of socket messages sent by the process;
%k number of signals delivered to the process;
%C name and cmd line args of the command being timed;
%x exit status of the command;

tmpwatch

recursively removes files which haven’t been accessed for a given num of hours. Normally, ~ is used to clean up dirs which are used for temporary holding space such as /tmp.

tmpwatch [options] hours dirs

~ does not follow symlinks in the dirs it’s cleaning, does not switch filesystems, skips lost+found dirs owned by root, and only removes empty dirs and regular files. By default, ~ dates files by their atime. The dirs to clean up must be absolute paths.

tmpwatch -v -t 24 /home/alex/tmp

delete nothing, just show what will be removed if this cmd is used without -t option;

tmpwatch -v -d 8 /home/alex/tmp

delete recursively regular files in /home/alex/tmp that were accessed more than 8 hours ago, do not delete dirs;

Options

-v    --verbose

-a, --all

remove all file types, not just regular files and dirs;

-c, --ctime

make decision about deleting a file based on the file's ctime (inode change time); for dirs, base decision on mtime;

-d, --nodirs

do not attempt to remove dirs, even if they are empty;

-f, --force

remove even if root doesn't have write access;

-m, --mtime

make decision about deleting a file based on the file's modification time;

-s, --fuser

attempt to use the fuser cmd to see if a file is open before removing it;

-t, --test

go through all steps, but do not remove file;

-u, --atime

make decision about deleting a file based on the file's access time; this is default;

-x name, --exclude=name

skip the specified files (name must be an absolute path); if name is a dir, all files in this dir are skipped too;

If --atime, --ctime, --mtime are used in combination, the decision is based on the maximum of these times.

top

provides a dynamic real-time view of running system (see also htop).

top [options]

Command-line options

-d ss.tt

delay time between screen updates (seconds.tenths);

-h, -v

show procps library version, usage, and quit;

-n m

max number of iterations (frames) before exit;

-U name

monitor only processes with a UID or user name given (matches real, effective, saved, filesystem UIDs);

-u name

monitor only processes with an effective UID or user name given;

Interactive commands (global)
? help (also h);
A full-screen / alternate display mode toggle;
B bold disable / enable toggle;
d change delay time interval; you’ll be prompted to enter value in seconds; fractional values are allowed; values less than 1 sec are not reasonable, because ~ itself creates too much load on the system;
G choose another window / field group; you’ll be prompted to enter a number 1..4;
I Irix / Solaris mode toggle; in Solaris mode task’s CPU usage is divided by the total number of CPUs;
k kill a task; you’ll be prompted for PID; by default SIGTERM is sent; if you want to cancel, press ENTER at the PID prompt or 0 at the signal prompt;
q quit;
r renice a task; you’ll be prompted for PID and value; positive value will cause the process to lose priority, negative will cause a process to be viewed more favorably by the kernel;
u select user; you’ll be prompted for a username or effective UID; only processes of this user will be displayed; later, if you wish to monitor all tasks again, re-issue this cmd and press ENTER when prompted for username;
U select user; you’ll be prompted for a username or UID (real, effective, saved, filesystem); only processes belonging to this user will be displayed;
W write the configuration file (saves your options, toggles, etc);
Z change color mapping;
Interactive commands (summary area)
l toggle load average / uptime;
m toggle memory / swap usage;
t toggle task / cpu states;
1 (one, digit) toggle single / separate cpu states;
Interactive commands (task area)
b bold / reverse toggle;
c cmd line / program name toggle;
i idle processes toggle; display all, or just active tasks;
f,o this keys display separate screens where you can change which fields are displayed and their order;
S cumulative time mode toggle; if on, the cpu time of children (already gone) is added to the cpu time of process itself;
n,# set max tasks; you will be prompted to enter the number;
x column highlight toggle (highlights current sort field, if on);
y row highlight toggle (highlights running tasks, if on);
z color / mono toggle;
Sorting of task window
Shift + M   sort by %MEM (obsolete);
Shift + N   sort by PID (obsolete);
Shift + P   sort by %CPU (obsolete);
Shift + T   sort by TIME+ (obsolete);

The following interactive cmds will only be honored when the current sort field is visible:

< move sort field left;
> move sort field right;

The following interactive cmds will always be honored whether or not the current sort field is visible:

F,O select sort field (separate screen will be displayed);
R reverse / normal sort field toggle (switches between high-to-low and low-to-high order);
Description of fields
PID process ID;
PPID parent process ID;
RUSER real user name;
UID user ID;
USER user name;
GROUP group name;
TTY controlling tty; this is usually the device (serial port, pty, etc) from which the proc was started;
PR kernel scheduling priority of the task;
NI the nice value of the task; negative means higher priority, positive means lower priority; zero means that priority will not be ajusted in determinig a task’s dispatchability;
#C last used CPU (SMP);
%CPU CPU usage, %;
TIME total cpu time the task has used since it started;
TIME+ the same as TIME, but reflecting more granularity through hundreths of a second;
%MEM task’s current share of the available physical memory;
VIRT the total amount of virtual memory used by the task (Kb); it includes code, data, shared libraries and pages that have been swapped out;
SWAP the swapped out portion of a tasks’s virtual mem image;
RES the non-swapped physical memory a task has used;
CODE code size, Kb; also known as TRS, text resident set size;
DATA data + stack size, Kb (DRS, data resident set size);
SHR shared memory size, Kb;
nFLT page fault count;
nDRT dirty page count;
S process status (see ps);
Command command line or program name;
WCHAN sleeping in function (see ps);
Flags task flags (see ps);

touch

updates the access and modification time of a file.

touch [options] filename

If file filename does not exist, and cmd is invoked without -c, an empty file named filename will be created.

touch msg22.txt

set access and modification times of the specified file to the current time;

touch --date='Jan 15 2012 14:05:30' chk.dat

set access and modification times of the specified file (chk.dat) to Jan 15, 2012, 14:05:30;

touch -t 1201151405.30 chk.dat

works exactly like prev cmd;

touch -t 06301200 *.html

set access and mod times of all files with html extension in this dir to June, 30, 12:00;

Options

--help    --version

-a change only the access time;

-c, --no-create

do not create any files;

-d str, --date=str

parse str and use it instead of the current time;

-h, --no-dereference

affect each symlink instead of any referenced file (useful only on systems that can change the timestamps of a symlink);

-m change only the modification time;

-r file, --reference=file

use the times of file instead of the current time;

-t stamp

use [[CC]YY]MMDDhhmm[.ss] instead of the current time;

--time=word

same as -a, if word is atime, access, use; same as -m, if word is mtime, modify;

traceroute

attempts to trace the route an IP packet would follow to the specified inet host by launching probe pkts with a small ttl, then listening for an ICMP "time exceeded" reply from a gateway. ~ starts with a ttl = 1 and increases it by one until ICMP "port unreachable" (or TCP reset) is received: it means we got to the host, or hit a max 30 hops (default). Three probes (default) are sent at each ttl and a line is printed showing the ttl, gateway address, round trip time of each probe. The address can be followed by additional info when requested. If the probe answers come from different gateways, the address of each responding system will be printed. If there is no response within a 5s (default), an * is printed for that probe.

traceroute [options] host [pkt_len]

The only required param is the name or IP addr of the destination host. The optional pkt_len is the total size of the probing pkt (default is 60 bytes for IPv4, 80 bytes for IPv6). The specified size can be (in some situations) ignored or set to a min value.

traceroute www.acme.net

trace the route to the specified web-server; use default settings (udp pkts, "unlikely" ports, etc);

traceroute -n www.acme.net

trace the route to the specified web-server; use default settings, but do not try to map IPs to names (may be faster then previous);

traceroute -T -p 25 mx.acme.net

trace the route to the specified mail-server; use tcp/25;

When UDP probe pkts are used (default mode), dest port is set to an unlikely value, i.e., we hope that there is no app listening on this port, otherwise the response can be misleading. There are no such problems with ICMP or TCP (for TCP half-open technique is used, which prevents the probes to be seen by app on the dest host). TCP tracerouting should be used if firewall blocks the "unlikely" UDP ports and ICMP echoes (see the example above).

Some options

--help    -V

-4, -6

explicitly force IPv4 or IPv6 traceouting; by default ~ auto derives the appropriate prot from the name resolution; if resolving returns both IPv4 and IPv6 addresses, v4 is used;

-d enable socket level debugging (if kernel supports);
-e show ICMP extensions (RFC4884);
-F do not fragment probe pkts (for IPv4 DF bit is also set, that tells intermediate routers not to fragment remotely as well);

-f first_ttl

set TTL to start with (default is 1);

-g gateway

add an IP src routing option to the outgoing pkt that tells the network to route pkt through the specified gateway (most routers disable src routing for security); you can also specify a comma separated list of gateways; for IPv6, the form of num,addr,addr... is allowed, num is a route header type (default is 2); type 0 route header is deprecated;

-I use ICMP ECHO for probes (default is UDP);

-i iface

send pkts through the specified interface; by default, interface is selected according to the routing table;

-M method

method to be used; default means UDP, there are also icmp and tcp; the last two can be also specified with -I and -T; method-specific options can be passed by -O;

-m max_ttl

max time-to-live (max num of hops); the default is 30;

--mtu

discover MTU along the path (implies -F -N 1); new MTU is output once in a form F=n at the first probe of a router which requires such MTU to be reached (the corresponding "frag needed" ICMP msg is sent by the prev router);

-N num

the number of probe pkts to be sent out simultaneously (default is 16); a reasonably large num can speed up the whole process; but if routers or target host use ICMP rate throttling, large num can lead to a loss of some responses;

-n do not try to map IP addresses to hostnames;

-O opt

method-specific options (comma-separated list; also you can specify -O several times); to get available options, try -O help;

-P prot

use raw packet of the specified protocol; the default prot is 253 (RFC3692);

-p port

1) for UDP tracing, port is a dest port base and this num will be incremented by each probe; 2) for ICMP tracing, port is an initial icmp sequence value incremented by each probe; 3) for TCP tracing this is a usual TCP dest port to connect to (const value);

-q num

the number of probe pkts per hop (default is 3);

-r bypass normal routing tables and send directly to a host on an attached network; if the host is not on a directly-attached network, an error is returned (can be used to ping a local host through an interface that has no route through it);

-s src_addr

use an alternative source address (it must be the address of one of the interfaces); by default, the addr of the outgoing iface is used;

--sport=port

source port to use; it also implies -N 1; usually src ports are chosen by the system;

-t tos

for IPv4, setType of Service (TOS) and Precedence value; useful values are 16 (low delay) and 8 (high throughput); some TOS precendence values are available for superuser only; for IPv6, set the Traffic Control value;

-U send UDP probes to a particular dest port (i.e., do not increase port num after each probe); the default port is 53;
-UL use UDPLITE; the default port is 53;

-w time

time (in seconds) to wait for a response to a probe (default is 5s);

-ztime

min time interval between probes (default is 0); if time > 10, then it's in milliseconds, otherwise it's a number of seconds (float point values are valid too);

Methods

default is an old, traditional method used by default. Probe pkts are UDP datagrams with "unlikely" dest ports starting at 33434 (first probe), then incremented by one. These ports are expected to be unused, so the dest host normally returns "icmp unreach port". The result may be strange if some app listens on this port.

icmp is the most typical method nowdays. It uses ICMP echo pkts for probes. If you can ping the dest host, icmp tracerouting is O.K.

tcp is a modern method to bypass firewalls. It uses the constant dest port (default is 80). If some filters are present in the network path, then "unlikely" UDP ports and ICMP echoes may be filtered, and tracerouting stops at the firewall. In this case you should use some allowed prot/port combinations, like tcp/80 (for web servers) or tcp/25 (for mail servers). Note that this method uses the "half-open technique", which prevents apps on the dest host from seeing probes. We send TCP SYN, and receive RESET for non-listened ports, or TCP SYN+ACK for listening ports, then we send RESET (the remote tcp session is dropped, app sees nothing).

tcpconn is an initial implementation of tcp method. Do not use! - it opens session and can affect the listening app.

udp (see -U) uses UDP datagram with a constant dest port (by default 53). Like tcp, it is intended to bypass firewalls. However, in this case app on the dest host receives our probes (with random data), and can be confused. In most cases it will not respond, so we will never see the final hop in the trace.

udplite (see -UL) uses udplite datagram for probes with constant dest port (default is 53).

raw sends a raw packet of the specified protocol (see -P). No protocol-specific headers are used, IP header only.

Notes

TTL (Time to live) is a mechanism that limits the lifetime of data in a computer or network. TTL may be implemented as a counter or timestamp attached to or embedded in the data. Once the prescribed event count or timespan has elapsed, data is discarded. In computing apps, TTL is used to improve caching or privacy. In networking, TTL prevents a data pkt from circulating indefinitely.

TTL is an IPv4 term. In IPv6 it is known as Hop Limit. The corresponding field specifies a limit on the number of hops a packet is allowed before it should be discarded.

A hop takes place each time when the packets are passed from one router to another. Next hop is a routing term used for the next gateway (router) to which pkts should be forwarded along the path to their final destination.

tune2fs

adjusts tunable params of ext2/ext3/ext4 filesystem, or displays the current values of those params (-l). See also dumpe2fs.

tune2fs -l /dev/sda7

list the superblock contents of a filesystem on /dev/sda7 (this info you can also get using dumpe2fs);

tune2fs -c 50 -i 1m /dev/hdb3

force fs check after 50 mounts or 1 months, whichever comes first;

tune2fs -m 1 /dev/sdc2

set the percentage of the reserved blocks on the partition /dev/sdc2 to 1%; it's assumed that the filesystem's size is ~250GB, and the default 5% is an unreasonable waste of space;

tune2fs [options] device

Options
-c n set max mounts count between two fs checks; 0 disables checking; NOTE! That for safety reasons you should have either mount-count-based or time-based (see -i) checking;
-C n set the number of times fs has been mounted; use in conjunction with -c to force fsck at the next reboot;

-e opt

change the behaviour of the kernel code when errors are detected (in any case e2fsck will be started on the next boot); available options:

continuecontinue normal execution;
remount-ro remount filesystem read-only;
paniccause a kernel panic;

-E opts

set extended options for the filesystem:

stride=stride-size     configure fs for a RAID array with stride-size fs blocks (the num of blocks read or written to disk before moving to next disk); this mostly affects placement of fs metadata to avoid placing them on a single disk, which can hurt the performance;

stripe_width=stripe-width     configure fs for a RAID array with stripe-width fs blocks per stripe; this is typically be stride-size * N (the number of data disks in the RAID); this allows the block allocator to prevent read-modify-write of the parity in a RAID stripe if possible when the data is written;

hash_alg=algo     set the default hash algorithm used for filesystems with hashed b-tree dirs; valid algorithms are: legacy, half_md4, tea;

test_fs     set a flag in the filesystem superblock indicating that it may be mounted using experimental kernel code;

^test_fs     clear test flag, indicating the filesystem should only be mounted using production-level fs code;

-f force ~ to complete operation even if errors are met; useful when removing has_journal feature from fs with an external journal that is not available, or fs is so corrupted that it appears to have an external journal; NOTE! That removing an external journal from fs which was not cleanly unmounted without first replaying the external journal can result in severe data loss and fs corruption;

-g grp

set group which can use the reserved filesystem blocks;

-i n[d|w|m]

set max time between two fs checks (days, weeks or months); 0 disables the time-dependent checks;

-j add an ext3 journal to the filesystem; unless -J is specified, the default journal params will be used to create an appropriately sized journal (based on fs size) stored within the filesystem; if this option is used to create a journal on a mounted fs, an immutable file .journal will be created in the top-level dir of fs; while checking unmounted filesystems, e2fsck will move .journal files to the invisible, reserved journal inode; for all filesystems except / (root), this happens automatically during next reboot; since the root fs is mounted read-only, e2fsck must be run from a rescue disk in order to effect this transition; on some systems (e.g., Debian), if an initial ramdisk is used, the initrd scripts will auto convert an ext2 root fs to ext3 if /etc/fstab specifies ext3 for the root fs;

-J param

override the default ext3 journal params using one of the following options (they are mutually exclusive):

size=n     create an internal (stored inside fs) journal of n MB; the size must be at least 1024 fs blocks (i.e., 1MB if using 1k blocks, 4MB if using 4k blocks, etc.), but no more than 102,400 fs blocks;

device=ext_journal     attach filesystem to the journal block device located on ext_journal;

-l list the contents of the filesystem superblock;

-L label

set the volume label of the filesystem (16 char max);

-m n set the percentage of the reserved filesystem blocks (default is 5%);

-M dir

set the last mounted dir for the filesystem;

-o [^]options

set/clear the indicated default mount options in the filesystem (a comma-separated list, '^' clears the specified option); the following options can be set or cleared using ~:

debug     enable debugging code for this filesystem;

bsdgroups     emulate BSD behaviour when creating new files (they will take the group-id of the dir in which they were created);

user_xattr     enable user-specified extended attributes;

acl     enable Posix Access Control Lists;

uid16     disable 32-bit UIDs and GIDs;

journal_data     when the filesystem is mounted with journalling enabled, all data (not just metadata) is committed into the journal prior to being written into the main fs;

journal_data_ordered     when the filesystem is mounted with journalling enabled, all data is forced directly out to the main fs prior to its metadata being committed to the journal;

journal_data_writeback     when the filesystem is mounted with journalling enabled, data may be written into the main fs after its metadata has been committed to the journal;

-O [^]features

set/clear fs feature; multiple features can be specified in a comma-separated list, where ^ clears, + (or no prefix) sets the feature. There are:

dir_index     use hashed B-trees to speed up lookups in large dirs;

filetype     store file type info in the directory entries;

flex_bg     (ext4) allow bitmaps and inode tables for a block group to be placed anywhere on the storage media; ~ does not relocate inode tables and allocation bitmaps, as mke2fs does when it creates fs with flex_bg enabled;

has_journal     use a journal to ensure fs consistency even across unclean shutdowns (equivalent to -j option);

large_file     allow files greater than 2GB (modern kernels auto set this feature when a big file is created);

resize_inode     reserve space so that the block grp descriptor table may grow up in the future; ~ only clears this feature;

sparse_super     limit the number of backup superblocks to save space on large filesystems;

uninit_bg     (ext4) allow kernel to initialize bitmaps and inode tables and keep a high watermark for the unused inodes to reduce e2fsck time; the first check after enabling this feature will take the full time, but the subsequent runs will be essentially shorter (it actually depends on fs space usage);

Note! After setting/clearing filetype, resize_inode, sparse_super, uninit_bg, run e2fsck to return fs to a consistent state; after setting dir_index feature, e2fsck -D can be run to convert existing dirs to the hashed B-tree; NOTE! enabling certain features may prevent fs from being mounted by the kernel that does not support those features;

-r n set the number of the reserved filesystem blocks;

-T time

set the time fs was last checked by e2fsck; the time format is YYYYMMDD[HH[MM[SS]]] or now (curr date/time);

-u user

set the user who can use the reserved fs blocks; user can be username or numeric UID (superblock stores UID anyway);

-U uuid

set the universally unique identifier (UUID) of the filesystem to uuid, which may be a random series of hex digits (see uuidgen) or one of the following options:

clear     clear the filesystem UUID;

randim     generate a new random UUID;

time     generate a new time-based UUID;

with mount, fsck, /etc/fstab you can specify UUID=uuid, instead of a block special device name;