substitute all occurrences in a file to something else: sed ’s/original/replacement/flag' filename
123456
cat text.txt
Peace is a lie, there is only passion.
Through passion, I gain strength.
Through strength, I gain power.
Through power, I gain victory.
Through victory, my chains are broken.
Changed the I to a we and redirect to a new file:
12345678
sed 's/I/we/g' text.txt > altered.txt
cat altered.txt
Peace is a lie, there is only passion.
Through passion, we gain strength.
Through strength, we gain power.
Through power, we gain victory.
Through victory, my chains are broken.
The Force shall free me.
diff
compare files line by line
compare files side by side
1234567
diff -y text.txt altered.txt
Peace is a lie, there is only passion. Peace is a lie, there is only passion.
Through passion, I gain strength. | Through passion, we gain strength.
Through strength, I gain power. | Through strength, we gain power.
Through power, I gain victory. | Through power, we gain victory.
Through victory, my chains are broken. Through victory, my chains are broken.
The Force shall free me. The Force shall free me.
man
an interface to the on-line reference manuals
search manpages by keyword
123456
man -k print | head -n 5
fmtmsg (3) - print formatted error messages
isprint (3) - character classification routines
iswprint (3) - test for printing wide character
netstat (8) - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
abrt-action-list-dsos (1) - Prints out DSO from mapped memory regions.
umask
display or set the file creation mask
It can be used to remove, but not add permissions
1234
umask
0022
umask -S
u=rwx,g=rx,o=rx
info
read Info documents
touch
Update the access and modification times of each FILE to the current time
r FILE –> use this file’s times instead of current time
whatis
display manual page descriptions
123
whatis ip
ip (7) - Linux IPv4 protocol implementation
ip (8) - show / manipulate routing, devices, pol...
apropos
search the manual page names and descriptions
1234567891011
apropos network | tail
teamnl (8) - team network device Netlink interface tool
tracepath (8) - traces path to a network host discoveri...
tracepath6 (8) - traces path to a network host discoveri...
traceroute (8) - print the route packets trace to networ...
traceroute6 (8) - print the route packets trace to networ...
tshark (1) - Dump and analyze network traffic
umount.nfs (8) - unmount a Network File System
usernetctl (8) - allow a user to manipulate a network in...
wget (1) - The non-interactive network downloader.
wireshark (1) - Interactively dump and analyze network ...
uniq
report or omit repeated lines
D # print all duplicate lines
u # only print unique lines
it won’t detect repeated lines unless they are adjacent. Sort first
sort
sort lines of text files
fmt
simple optimal text formatter
u # uniform spacing: one space between words, two after sentences
1234
[root@tron ~]# cat test.txt
Test. Next sentence. This doesn't look right
[root@tron ~]# fmt -u test.txt
Test. Next sentence. This doesn't look right
nl
number lines of files
123456
nl test.txt
1 First line
2 Second line
3 Third line
updatedb
creates or updates a database used by locate(1). It’s usually run daily by cron(8) to update the default database.
tty
print the file name of the terminal connected to standard input
12
tty
/dev/pts/1
type
indicate how each name would be interpreted if used as a command name
12
type ls
ls is aliased to `ls --color=auto'
tree
list contents of directories in a tree-like format
find / -size 10M -type f # find files whose size is 10 megabytes
type d/c/l/f # directories/character devices/symlinks/files
user # owned by username
exec ‘{}’ + # execute cmd on results of the find cmd
print # print full filename to stdout, followed by newline
name “value” # find values that start with the name
iname # ignore case
not -name # not
size +/– c/k/m/G # size in bytes; + =larger than, – = smaller than; c = bytes, k = kilobytes, m = megabytes, G = gigabytes
mtime # modification time
atime # access time
which
shows the full path of (shell) commands. It does this by searching for an executable or script in the directories listed in the environment variable PATH
12
which python
/usr/bin/python
locate
find files by name. Reads one or more databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line.
It is much faster than find. On most systems, locate is a link to slocate, which includes security features that prevent users from seeing files in directories they shouldn’t be able to access
_______________________________________
/ Kindness is a language which the deaf \
| can hear and the blind can read. |
| |
\ -- Mark Twain /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||