Skip to content

Commit a11dca2

Browse files
committed
Split utils some more, add printing utils
1 parent 86716f9 commit a11dca2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1294
-856
lines changed

README.md

+41-21
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,41 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
2323
1. [System Call](system-call/)
2424
1. [sysctl](sysctl.md)
2525
1. [Special files](special-files.md)
26-
1. [proc filesystem](proc-filesystem.md)
27-
1. [dev filesystem](dev-filesystem.md)
26+
1. [proc filesystem](proc-filesystem.md)
27+
1. [dev filesystem](dev-filesystem.md)
28+
1. [mknod](mknod.md)
2829
1. Initialization
2930
1. [Install OS](install-os.md): how to install a new OS
3031
1. [Boot](boot.md)
3132
1. [Init](init.md): System V, Upstart
32-
1. Base topics
33-
1. [Filesystem](filesystem.md) POSIX file permissions.
34-
1. [Hardlink](hardlink.md)
35-
1. [File permissions](file-permissions.md): filesystem, hard disks, mounting, partitions
36-
1. [Terminal](terminal.md): terminal emulators, ANSI escapes, control characters
37-
1. [Guake](guake.sh)
33+
1. System information
34+
1. [lsb_release](lsb_release.md)
35+
1. [uname](uname.md)
36+
1. Hardware
37+
[lspci](lspci.md)
38+
1. [Filesystem](filesystem.md)
39+
1. [File permissions](file-permissions.md)
40+
1. [Hardlink](hardlink.md)
41+
1. [badblocks](badblocks.md)
42+
1. [blkid](blkid.md)
43+
1. [chown](chown.sh)
44+
1. [chmod](chmod.sh)
45+
1. [du](du.md)
46+
1. ext filesystems
47+
1. [e2label](e2label.md)
48+
1. [e2fsck](e2fsck.md)
49+
1. [e2fsprogs](e2progs.md)
50+
1. [mke2fs](mke2fs.md)
51+
1. [fdisk](fdisk.md)
52+
1. [fuser](fuser.md)
53+
1. [lsblk](lsblk.md)
54+
1. [mktemp](mktemp.md)
55+
1. [pathchk](pathchk.md)
56+
1. [ramfs](ramfs.md)
57+
1. [swap partition](swap-partition.md)
58+
1. [UUID](uuid.md)
59+
1. [Terminal](terminal.md): terminal emulators, ANSI escapes, control characters
60+
1. [Guake](guake.sh)
3861
1. Stream and file manipulation
3962
1. [cat](cat.md)
4063
1. [head](head.md)
@@ -86,14 +109,6 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
86109
1. File managers
87110
1. [Krusader](krusader.md)
88111
1. [vifm](vifm.md)
89-
1. Partitions, filesystems
90-
1. [badblocks](badblocks.md)
91-
1. [blkid](blkid.md)
92-
1. [du](du.md)
93-
1. [e2fsck](e2fsck.md)
94-
1. [e2fsprogs](e2progs.md)
95-
1. [lsblk](lsblk.md)
96-
1. [swap partition](swap-partition.md)
97112
1. [Compilation and libraries](compile.md)
98113
1. [GDB](gdb.md)
99114
1. [Library](library.md)
@@ -172,25 +187,30 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
172187
1. [RST](rst/)
173188
1. [Virtual machine](virtual-machine/)
174189
1. [Docker](docker/)
190+
1. [User mode Linux](user-mode-linux.md)
175191
1. [Vagrant](vagrang/)
176192
1. [Configuration automation](config-automation.md)
177193
1. [chef](chef/)
178194
1. [puppet](puppet.md)
179-
1. Hardware
180-
[lspci](lspci.md)
195+
1. Printing
196+
1. [CUPS](cups.md)
197+
1. [lp](lp.md)
198+
1. [lpstat](lpstat.md)
199+
1. [lpoptions](lpoptions.md)
200+
1. [system-config-printer](system-config-printer.md)
181201
1. Misc
202+
1. [cron](cron.sh)
182203
1. [logrotate](logrotate.md)
183204
1. [factor](factor.md)
184205
1. [xargs](xargs.md)
185206
1. [Bibliography](bibliography.md)
186207

187208
## WIP
188209

210+
1. Filesystem
211+
[eCryptfs](ecryptfs.md)
189212
1. [Hardware](hardware.md)
190213
1. [lshw](lshw.md)
191-
1. Printer
192-
1. [system-config-printer](system-config-printer.md)
193-
1. CUPS
194214
1. [gcov](gcov.md)
195215
1. Misc
196216
1. [sys-filesystem](sys-filesystem.md)

Re

Whitespace-only changes.

arch.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# arch
2+
3+
Coreutils.
4+
5+
Same as `uname -m`:
6+
7+
arch
8+
9+
Sample outputs:
10+
11+
x86_64
12+
13+
So basically an alias.

chmod.sh

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
## chmod
2+
3+
# POSIX
4+
5+
# Change file permissions
6+
7+
# Syntax:
8+
9+
# chomod [ugoa][+-=][rwxXst]+
10+
11+
# Make f executable for all (owner, group and other);
12+
13+
chmod a+x "$f"
14+
15+
# Makes f readable for all:
16+
17+
chmod a+r "$f"
18+
19+
# The difference between using `a` and nothing is that when using
20+
# nothing `umask` comes into play.
21+
22+
umask 002
23+
chmod +w "$f"
24+
stat -c "%a" "$f"
25+
#220
26+
chmod a=w "$f"
27+
stat -c "%a" "$f"
28+
#222
29+
chmod o=w "$f"
30+
stat -c "%a" "$f"
31+
#002
32+
33+
# Make f not executable for all:
34+
35+
chmod -x "$f"
36+
37+
# Make file not executable and not writeble by all:
38+
39+
chmod =r "$f"
40+
41+
# Make f executable for owner:
42+
43+
chmod u+x "$f"
44+
45+
# Makes f executable for group and other:
46+
47+
chmod go+x "$f"
48+
49+
# Makes f readable and writible for all:
50+
51+
chmod +rw "$f"
52+
53+
# Same as `chmod =rwx`:
54+
55+
chmod 777 "$f"
56+
57+
## sticky bit, suid sgid bits
58+
59+
# Sticky bit:
60+
61+
chmod 1000 "$f"
62+
chmod o=t "$f"
63+
chmod a=t "$f"
64+
stat -c "%A" "$f"
65+
#---------T
66+
chmod a-t "$f"
67+
chmod u=t "$f"
68+
chmod g=t "$f"
69+
stat -c "%A" "$f"
70+
#---------T
71+
chmod =s "$f"
72+
chmod 6000
73+
#set suid and sgid
74+
chmod u=s "$f"
75+
chmod 4000
76+
#set suid and sgid
77+
chmod g=s "$f"
78+
chmod 2000
79+
80+
# Can't clear them on numeric mode, only symbolic:
81+
82+
chmod 7777 f
83+
stat -c "%A" "$f"
84+
#-rwsrwsrws
85+
chmod 0 f
86+
stat -c "%A" "$f"
87+
#---S--S--T
88+
chmod a-st f
89+
stat -c "%A" "$f"
90+
#----------
91+
92+
# Can only change permissions for files you own
93+
# even if you do not have all the permissions on the file:
94+
95+
su a
96+
touch a
97+
chmod 777 a
98+
su b
99+
if ! chmod 770 a; then assert true; fi
100+

chown.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## chown
2+
3+
# POSIX 7
4+
5+
# Change owner and group of files.
6+
7+
# You must use sudo to do this, because otherwise users would be able to:
8+
9+
# - steal ownership of files
10+
# - git ownership to users who do not want to own the files
11+
12+
su a
13+
mkdir d
14+
touch d/f
15+
sudo chown newuser:newgroup d
16+
#must use sudo to chown
17+
[ `stat -c '%U' d` = newuser ] || exit 1
18+
[ `stat -c '%G' d` = newgroup ] || exit 1
19+
[ `stat -c '%U' d/f` = a ] || exit 1
20+
21+
# `-R` for recursive operation:
22+
23+
su a
24+
mkdir d
25+
touch d/f
26+
sudo chown b d
27+
[ `stat -c '%U' d` = newuser ] || exit 1
28+
[ `stat -c '%G' d` = newgroup ] || exit 1
29+
[ `stat -c '%U' d/f` = newuser ] || exit 1
30+
[ `stat -c '%G' d/f` = newgroup ] || exit 1
31+
32+
# To change only user:
33+
34+
sudo chown newuser
35+
36+
# To change only group:
37+
38+
sudo chown :newgroup
39+

cron.sh

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
## cron
2+
3+
# Tell the computer to do things at specified times automatially.
4+
5+
## crontab
6+
7+
# POSIX 7.
8+
9+
# Utility to manage crobjobs.
10+
11+
# It is basically a frontend for the `/etc/crontab` file which an be edited directly.
12+
13+
# It is not possible launch graphical applications via cron!
14+
15+
# Edit user cron jobs in vim
16+
17+
crontab -e
18+
19+
# Sample line:
20+
21+
1 2 3 4 5 /path/to/cmd.sh arg1 arg2 >/dev/null 2>&1
22+
23+
# Fields:
24+
25+
# - 1: Minute (0-59)
26+
# - 2: Hours (0-23)
27+
# - 3: Day (0-31)
28+
# - 4: Month (0-12 [12 == December])
29+
# - 5: Day of the week(0-7 [7 or 0 == sunday])
30+
# - /path/to/command - Script or command name to schedule#
31+
32+
# Special notations:
33+
34+
# - * : every
35+
# - */5 : every five
36+
# - 1,3,6 : several
37+
# - 1-5 : ranges
38+
39+
# Convenient altenatives to the fields:
40+
41+
# - @reboot Run once, at startup.
42+
# - @yearly Run once a year, "0 0 1 1 *".
43+
# - @annually (same as @yearly)
44+
# - @monthly Run once a month, "0 0 1 * *".
45+
# - @weekly Run once a week, "0 0 * * 0".
46+
# - @daily Run once a day, "0 0 * * *".
47+
# - @midnight (same as @daily)
48+
# - @hourly Run once an hour, "0 * * * *".
49+
50+
# Example:
51+
52+
@daily /path/to/cmd.sh arg1 arg2 >/dev/null 2>&1
53+
54+
# `>/dev/null 2>&1` prevents cron from sending notification emails.
55+
56+
# Otherwise if you want them add:
57+
58+
59+
60+
# to the config file.
61+
62+
# List all cronjobs:
63+
64+
crontab -l
65+
66+
# List all cronjobs for a given user:
67+
68+
crontab -u user -l
69+
70+
# Erase all cronjobs:
71+
72+
crontab -r
73+
74+
# Erase all cronjobs for a given user only
75+
76+
crontab -r -u username
77+
78+
## batch
79+
80+
# POSIX 7
81+
82+
# Superset of `at`.
83+
84+
# Execute only when system load average goes below 1.5,
85+
# starting from now!
86+
87+
cd "`mktemp -d`"
88+
echo "touch a" | batch
89+
90+
# Same, but with at you can change to any time:
91+
92+
echo "touch a" | at -q b now
93+
94+
## at
95+
96+
# Schedule job at a single specified time.
97+
98+
# Not for a periodic jobs.
99+
100+
cd "`mktemp -d`"
101+
echo "touch a" | at now + 1 minutes
102+
#in one minute `test -f a`
103+
echo "echo a" | at now + 1 minutes
104+
#nothing happens!
105+
#of course, job does not run in current shell
106+
echo "xeyes" | at now + 1 minutes
107+
#nothing happens
108+
109+
# List jobs:
110+
111+
atq
112+
113+
# Remove job with id 1:
114+
115+
atrm 1
116+
117+
# Id can be found on atq output.
118+
119+
#inner workings
120+
121+
echo "touch a" | at now + 10 minutes
122+
d=/var/spool/cron/atjobs
123+
sudo cat "$d/$(sudo ls "$d" | head -n 1)"
124+
#note how the entire environment
125+
#and current dir are saved and restored
126+
127+
sudo cat /usr/lib/cron/at.allow
128+
#if exists, only listed users can `at`
129+
sudo cat /usr/lib/cron/at.deny
130+
#if allow exists, this is ignored!
131+
#if not, denies only to listed users

0 commit comments

Comments
 (0)