change ``bash headers to ``sh

This commit is contained in:
2025-08-22 15:59:04 +02:00
parent 3e049e1687
commit 8eea348112
80 changed files with 773 additions and 555 deletions

View File

@@ -4,43 +4,43 @@ tags: [ "basics", "time" ]
---
Install with:
```bash
```sh
sudo apt install at
```
Enable the daemon service with:
```bash
```sh
sudo systemctl enable --now atd
```
Then jobs can be specified with absolute time, such as:
```bash
```sh
at 16:20
```
```bash
```sh
at noon
```
```bash
```sh
at midnight
```
```bash
```sh
at teatime
```
Type in your command, e.g.:
```bash
```sh
touch /tmp/$FILE.txt
```
The jobs can also be specified relative to the current time:
```bash
```sh
at now +15 minutes
```
@@ -50,7 +50,7 @@ Finally, accept the jobs with ^D.
Display a list of commands to run with:
```bash
```sh
atq
```
@@ -58,7 +58,7 @@ atq
This will print all pending IDs. Remove a job by the ID with:
```bash
```sh
atrm 2
```
@@ -68,7 +68,7 @@ Check `/var/spool/atd/` to see the jobs.
Automatically add a job for later, by setting the date, then using echo for the command.
```bash
```sh
t="$(date -d "2 minutes" +%R)"
echo "fortune > ~/$FILE" | at "$t"
watch cat $FILE

View File

@@ -9,13 +9,13 @@ Don't worry about understanding any of it, just type it in and the habit forms p
You start in a dark room. You want to know where you are by **p**rinting out your **w**orking '**d**irectory' (i.e. 'location'):
```bash
```sh
pwd
```
Have a look at what is here:
```bash
```sh
ls
```
@@ -23,11 +23,11 @@ If you get no response, the list of items is "", meaning "nothing here".
Have a look at **a**ll the files:
```bash
```sh
ls -a
```
```bash
```sh
. ..
```
@@ -35,38 +35,38 @@ So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the
Change directory (`cd`) down one level:
```bash
```sh
cd ..
```
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
```bash
```sh
cd bob
```
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
```bash
```sh
cd /
```
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up:
```bash
```sh
du iptables
```
That's the number of kilobytes the file is taking up.
Do the same again, but in a human-readable format:
```bash
```sh
du -h iptables
```
The `du` program has `-h` for 'human', '-s' for 'short', and a bunch of other commands.
Have a look at the manual and try another command:
```bash
```sh
man du
```
@@ -74,7 +74,7 @@ Once you're done, press 'q' to quit the manual page and try the extra `du` flag
Now you can try to gain super-powers and take over the system:
```bash
```sh
sudo -i
```
@@ -82,61 +82,61 @@ At this point, you are 'root'.
All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine.
Best to exit out of the root account:
```bash
```sh
exit
```
Go find a file that isn't a directory. You can tell which is which with:
```bash
```sh
ls -l
```
A directory starts with a 'd', like this:
```bash
```sh
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
```
A standard file starts with '-', like this:
```bash
```sh
`-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname`
```
Look inside the file /etc/hostname to find out your computer's name:
```bash
```sh
cat /etc/hostname
```
Print out the words "hello world":
```bash
```sh
echo "hello world"
```
Move back to your home directory:
```bash
```sh
cd
```
Take the words 'hello world', and put them in 'my_file':
```bash
```sh
echo 'hello world' > my_file
```
Measure the disk usage of that file, then put the results at the bottom of the file:
```bash
```sh
du $FILE >> $FILE
```
And check the results:
```bash
```sh
cat $FILE
```
@@ -148,7 +148,7 @@ Press tab after typing a few keys and bash will guess what you're trying to typ
Look at your file's owner:
```bash
```sh
ls -l $FILE
```
@@ -156,19 +156,19 @@ If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is own
Take your file and change the owner to root:
```bash
```sh
sudo chown root $FILE
```
Change the same file so it's owned by the group 'audio':
```bash
```sh
sudo chown :audio $FILE
```
Check you did that correctly:
```bash
```sh
ls -l my_file
```
@@ -176,7 +176,7 @@ ls -l my_file
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
```bash
```sh
rm $FILE
```
@@ -184,32 +184,32 @@ You'll see you're not allowed, because you don't own it.
Look at which groups you're in:
```bash
```sh
groups
```
Change the file so that members of the audio group can write to the file:
```bash
```sh
sudo chmod g+w $FILE
```
Check you got it right with `ls -l`:
```bash
```sh
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
```
Try to delete the file again:
```bash
```sh
rm my_file
```
If you can't, you're not in the audio group. Add yourself. You'll need to *modify* your *user account*, by **a**ppending 'audio' to your list of groups.
Use `-a` to **a**ppend, and `-G`, to say you're modifying groups:
```bash
```sh
sudo usermod -a -G audio [ your username here ]
```
@@ -219,19 +219,19 @@ Now you should be able to remove (delete) the file. Remember, that using 'rm fi
Make a directory called 'new test':
```bash
```sh
mkdir 'new test'
```
Make two directories, called 'A', and 'Z':
```bash
```sh
mkdir A Z
```
Make a single directory called 'A Z'
```bash
```sh
mkdir 'A Z'
```
@@ -239,19 +239,19 @@ mkdir 'A Z'
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
```bash
```sh
du -sch * > A/'disk usage'.txt
```
Look at your file:
```bash
```sh
cat A/'disk usage.txt'
```
If you think you have too much information, use `grep` to just get the one line of text you want:
```bash
```sh
grep total A/disk\ usage.txt
```
@@ -259,7 +259,7 @@ The `grep` program also has a manual ('man page'). You should find out what tha
Start the manual:
```bash
```sh
man du
```
@@ -267,7 +267,7 @@ Then search for `-c` by pressing `/`. Your final keys should be `man du`, then
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
```bash
```sh
man ls | grep human
```
@@ -275,25 +275,25 @@ Now use that flag that you've found in combinatin with the `-l` flag to look at
Remove the directory 'Z':
```bash
```sh
rmdir Z
```
Remove the directory 'Z':
```bash
```sh
rmdir Z
```
And then remove all the rest:
```bash
```sh
rmdir *
```
The 'A' directory will not budge because it's not empty. Remove it recursively, so the computer will remove the things inside the directory as well as the directory itself:
```bash
```sh
rm -r A
```
@@ -303,11 +303,11 @@ You get a package manager which installs programs, fonts, et c.
If you're on something like Debian, you'll have `apt`, or if you're on something like Red Hat, you'll have `yum`.
If unsure, ask where a program is:
```bash
```sh
whereis yum
```
```bash
```sh
whereis apt
```
@@ -315,14 +315,14 @@ If you get a hit, you can use whatever program that is to install things.
Set a reminder of your package manager:
```bash
```sh
echo my package manager is yum | lolcat
```
If that failed it's because you don't have `lolcat` installed.
Install lolcat:
```bash
```sh
sudo apt install lolcat
```
@@ -330,13 +330,13 @@ Try the same command again.
Search for things you want, like `libreoffice`, or `gimp`:
```bash
```sh
apt search libreoffice
```
... then install one of them with:
```bash
```sh
apt install $PROGRAM
```

View File

@@ -5,37 +5,37 @@ tags: [ "basics", "time" ]
Show system time:
```bash
```sh
date
```
Show hardware time:
```bash
```sh
sudo hwclock -r
```
Change system time to match hardware time:
```bash
```sh
sudo hwclock --hctosys
```
Change hardware time to match system time:
```bash
```sh
sudo hwclock --systohc
```
Manually set the hardware time to a specified date:
```bash
```sh
sudo hwclock --set --date="8/25/19 13:30:00"
```
## Normal Date
```bash
```sh
date +%d/%m/%y
```
@@ -45,7 +45,7 @@ Computers started counting time on January 1st, 1970, and added one second-per-s
Track the time in Unix-time:
```bash
```sh
date +%s
```
@@ -55,13 +55,13 @@ Servers which take their time from an observatory we call Stratum 1 servers. Se
Install ntp with:
```bash
```sh
sudo apt-get install -y ntp
```
The shell command for this is `ntpq`. Monitor the service providers using:
```bash
```sh
ntpq -p
```

View File

@@ -5,32 +5,32 @@ tags: [ "basics", "format", "json" ]
Put output into column.
```bash
```sh
du -h /etc/* | column
```
Reformat file with an explicit separator (`-s`):
```bash
```sh
column -ts: /etc/passwd
```
Give columns names (`-N`), so you can hide some (`-H`):
```bash
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
```
Reorder with `-O` (unspecified items remain):
```bash
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
```
Output to json format with `-J`:
```bash
```sh
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
```

View File

@@ -46,7 +46,7 @@ esac
# While and Until
This prints from 1 until 9.
```bash
```sh
COUNTER=1
while [ $COUNTER -lt 2 ]; do
> ((COUNTER++))
@@ -58,7 +58,7 @@ There's also 'until', which stops when something is true, rather than keeping go
# For
```bash
```sh
for i in $( ls ); do
> du -sh $i
> done
@@ -70,19 +70,19 @@ The sequences tool counts up from X in jumps of Y to number Z.
Count from 1 to 10.
```bash
```sh
seq 10
```
Count from 4 to 11.
```bash
```sh
seq 4 11
```
Count from 1 to 100 in steps of 5.
```bash
```sh
seq 1 5 100
```

View File

@@ -8,13 +8,13 @@ The `cronie` program is also known as `crond`.
## Install
```bash
```sh
sudo apt search -n ^cron
```
Once installed, search for the service name, and start it.
```bash
```sh
sudo systemctl list-unit-files | grep cron
sudo systemctl enable --now $NAME
```
@@ -23,20 +23,20 @@ sudo systemctl enable --now $NAME
Show your current crontab:
```bash
```sh
crontab -l
```
You can put this in a file and edit it:
```bash
```sh
crontab -l > $filename
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
```
Then apply that crontab:
```bash
```sh
crontab $filename
rm $filename
```
@@ -70,7 +70,7 @@ Doing the same thing, but only in February, would be:
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
```bash
```sh
echo "HOME=$HOME" > $filename
crontab -l >> $filename
crontab $filename
@@ -80,7 +80,7 @@ crontab $filename
You can give it your usual `$PATH` variable like this:
```bash
```sh
echo $PATH > $filename
crontab -l >> $filename
crontab $filename
@@ -99,13 +99,13 @@ You can simply do this:
You can execute a script as root by putting it into a directory, instead of in the tab.
Look at the available cron directories:
```bash
```sh
ls -d /etc/cron.*
```
Make a script which runs daily:
```bash
```sh
f=apt_update.sh
echo '#!/bin/bash' > $f
echo 'apt update --yes' >> $f
@@ -117,7 +117,7 @@ sudo mv $f /etc/cron.daily/
Run-parts runs all executable scripts in a directory.
```bash
```sh
run-parts /etc/cron.hourly
```

View File

@@ -5,7 +5,7 @@ tags: [ "basics" ]
Compose a statement for execution.
```bash
```sh
x='echo $y'
echo $x
y=dragon
@@ -14,7 +14,7 @@ eval "$x"
The results remain in the current shell, unlike sub-shells.
```bash
```sh
b=basilisk
sh -c 'echo $b'
eval "g=goblin"

View File

@@ -11,20 +11,20 @@ This ID is called the 'inode'.
Create a file, and a hard link:
```bash
```sh
fortune > $file_1
mkdir -p x/y/z/
ln $file_1 x/y/z/$file_2
```
Have a long look at the file with the `-l` flag, and check the inode with `-i`:
```bash
```sh
ls -li $file_1 x/y/z/$file_2
```
Since they are the same file, you can make a change to one, and it changes both:
```bash
```sh
fortune | tee x/y/z/$file_2
cat $file_1
cat x/y/z/$file_2

View File

@@ -7,7 +7,7 @@ If you want to kill a program in a graphical environment, open a terminal and ty
# Graphical Programs
```bash
```sh
xkill
```
@@ -17,7 +17,7 @@ Then click on the application which you want to kill.
To kill a program, find it with:
```bash
```sh
pgrep discord
```
@@ -25,7 +25,7 @@ This will give you the UUID, e.g. `19643`.
Kill the program with:
```bash
```sh
kill 19643
```
@@ -33,7 +33,7 @@ kill 19643
To see an ordered list of termination signals:
```bash
```sh
kill -l
```
@@ -49,7 +49,7 @@ Higher numbers are roughly equivalent to insistence.
For example:
```bash
```sh
kill -1 3498
```
@@ -57,7 +57,7 @@ This roughly means 'maybe stop the program, if you can, maybe reload'.
Or the famous:
```bash
```sh
kill -9 3298
```

View File

@@ -8,25 +8,25 @@ A list of supported locales is available at /usr/share/i18n/SUPPORTED
See a full list with:
```bash
```sh
cat /usr/share/i18n/SUPPORTED
```
Take the first portion to generate full locale information for a region:
```bash
```sh
locale-gen ru_RU.UTF-8
```
Then use this for the current shell session with
```bash
```sh
LANG=ru_RU.utf8
```
Expand this to the entire system with:
```bash
```sh
export LANG=ru_RU.utf8
```
@@ -34,7 +34,7 @@ You can make this permanent for one user by adding this line to the ~/.profile o
Make it permanent for the entire system by editing:
```bash
```sh
sudo vim /etc/defaults/locale
```

View File

@@ -8,13 +8,13 @@ Firstly, your `ls` is probably aliased to something.
Check it with:
```bash
```sh
alias ls
```
If the prompt shows some alias, then start by removing it:
```bash
```sh
unalias ls
```
@@ -23,24 +23,24 @@ Now we can begin.
Check the most recently modified file:
```bash
```sh
ls -t
```
Reverse this with `tac` to see the file which has been unmodified the longest:
```bash
```sh
ls -t | tac
```
Group files by extension:
```bash
```sh
ls -X
```
Sort largest files first:
```bash
```sh
ls -X
```

View File

@@ -6,31 +6,31 @@ tags: [ "basics" ]
See running items in current terminal with
```bash
```sh
ps
```
or more with
```bash
```sh
ps -a
```
Or the entire system with
```bash
```sh
ps -e
```
Or the entire system with more information, BSD style, with:
```bash
```sh
ps aux
```
And then search for a particular program with
```bash
```sh
ps aux | grep cmus
```
@@ -40,19 +40,19 @@ Pause a job with ^z. Put it in the background with the '&' suffix.
List jobs in the current shell with
```bash
```sh
jobs
```
And then you can pull number 1 up again with
```bash
```sh
fg 1
```
Or continue running a stopped job with:
```bash
```sh
bg 1
```
@@ -62,31 +62,31 @@ This changes how nice a program is, from -20 to 19.
Install a program, but nicely, at nice value '10':
```bash
```sh
nice -10 sudo apt -y install libreoffice
```
Aggressively use Steam, with a nice value of '-13'.
```bash
```sh
nice --13 steam&
```
Find out that Steam's fucking everything up, so you change its nice value with 'renice':
```bash
```sh
renice --5 -p 3781
```
Nerf all of roach-1's processes:
```bash
```sh
renice 10 -u roach-1
```
... or the entire group
```bash
```sh
renice -14 -g hackers
```

View File

@@ -9,7 +9,7 @@ This & That
Refer to 'that last thing', and 'the first thing':
```bash
```sh
fortune -l > file1
cat !$ | tr -d u
diff !^ !$
@@ -17,7 +17,7 @@ diff !^ !$
**NB:** this can go wrong:
```bash
```sh
ls -l file1 file2
cat !^
```
@@ -36,7 +36,7 @@ Input Run-Commands (`~/.inputrc`)
Alias Expansion
---------------
```bash
```sh
echo '"\C- ": shell-expand-line' >> ~/.inputrc
exec bash
```
@@ -47,7 +47,7 @@ Try just `ls`, then 'Control + Space'.
Glob Expansion (`*`)
--------------------
```bash
```sh
echo '"\C-x": glob-expand-word' >> ~/.inputrc
exec bash
ls *<C-x>
@@ -63,13 +63,13 @@ Arbitrary Commands
Use `\n` as a 'newline' character to automatically press `<Return>`.
```bash
```sh
echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
exec bash
ls<C-y>
```
```bash
```sh
Control-l: "\C-u clear -x && ls\n"
exec bash
cd /etc/<C-l>
@@ -78,7 +78,7 @@ cd /etc/<C-l>
Readline as Vi
--------------
```bash
```sh
echo 'set editing-mode vi' >> ~/.inputrc
echo 'set keymap vi-insert' >> ~/.inputrc
exec bash
@@ -115,7 +115,7 @@ Fix Globs!
If you tried the previous commands then they will not work any more, because the `vi`-commands overwrite the other commands.
Remove them.
```bash
```sh
sed '/ vi/d' ~/.inputrc
sed -i '/ vi/d' ~/.inputrc
@@ -130,14 +130,14 @@ Vi-sibility
The `readline` prompt becomes confusing if you don't remember if you're in insert or normal mode.
But you can show the current mode in the prompt:
```bash
```sh
echo 'set show-mode-in-prompt on' >> ~/.inputrc
exec bash
```
Set new symbols for normal and insert mode:
```bash
```sh
echo 'set vi-ins-mode-string " "' >> ~/.inputrc
echo 'set vi-cmd-mode-string " "' >> ~/.inputrc
```
@@ -148,33 +148,33 @@ Fuzzy Sort
Check your repos for `sk-im`, and install.
The program is called `sk`.
```bash
```sh
FUZZY=sk
```
If you don't have it, `fzy` or `fzf` should work the same way.
```bash
```sh
FUZZY=fzy
```
Find some 'read-config' files to check out:
```bash
```sh
find . -maxdepth 2 -name "*rc"
find . -maxdepth 2 -name "*rc" | $FUZZY
```
And read some:
```bash
```sh
PAGER='less -R'
$PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)"
```
Make the change long-term:
```bash
```sh
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"'
alias | grep rrc= >> ~/.bash_aliases
```

View File

@@ -7,7 +7,7 @@ When a program encounters a soft link, it will make a guess at whether it shoul
To make a soft link to a file in the current directory, linking is easy:
```bash
```sh
fortune > $file_1
ln -s $file_1 $link_1
```
@@ -27,14 +27,14 @@ dir_0/
Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file:
```bash
```sh
cd dir_1
ln -s ../file_1 link_1
```
The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file:
```bash
```sh
ln -s ../file_1 dir_2/link_2
```
@@ -54,7 +54,7 @@ dir_0/
Since it's just an address, you can delete the original file, then make another.
```bash
```sh
rm file_1
ls -l dir_1/
fortune > file_1
@@ -65,7 +65,7 @@ cat dir_1/link_1
Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link):
```bash
```sh
ln -s -f ../dir_1/file_1 dir_2/link_2
cat dir_2/link_2
```

View File

@@ -6,7 +6,7 @@ tags: [ "basics", "time" ]
Set time to synchronize with an ntp server:
```bash
```sh
timedatectl set-ntp true
```
@@ -18,7 +18,7 @@ Local time is kept in /etc/localtime.
According to Dave's LPIC guide, you can set the local time by making asymboling link from your timezone to /etc/localtime, as so:
```bash
```sh
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
```
@@ -28,31 +28,31 @@ sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
See local time, language and character settings with:
```bash
```sh
locale
```
List available locales with:
```bash
```sh
locale -a
```
To see additional locales which are available (but not necessarily installed):
```bash
```sh
cat /usr/share/i18n/SUPPORTED
```
Set a supported locale with:
```bash
```sh
locale-gen pl_PL.UTF-8
```
Then set that language, with:
```bash
```sh
LANG=pl_PL.UTF-8
```
@@ -62,7 +62,7 @@ LANG=pl_PL.UTF-8
Glimpse an overview with:
```bash
```sh
ntpq -p
```
@@ -73,6 +73,6 @@ Usually this is run as a service, so just start that service.
If your clock drifts too far from the right time, it will not reset happily.
For it to reset like this:
```bash
```sh
sudo ntpd -q -g -x -n
```

View File

@@ -28,7 +28,7 @@ Each description-line starts with a tab.
To represent a file structure as a nested series of markdown lists, you can try this horrifying `sed` one-liner:
```bash
```sh
tree -tf --dirsfirst --gitignore --noreport --charset ascii | \
sed -e 's/| \+/ /g' \
-e 's/[|`]-\+/ */g' \

View File

@@ -6,23 +6,23 @@ tags: [ "basics" ]
Let's get some entries with 'getent', e.g. passwd or group.
```bash
```sh
getent passwd
```
```bash
```sh
getent group
```
Obviously:
```bash
```sh
getent shadow
```
## Examples
```bash
```sh
sudo adduser maestro
```
@@ -30,71 +30,71 @@ add user 'maestro'
This depends upon the settings in the /etc/default/useradd file and /etc/login.defs
```bash
```sh
sudo useradd -m pinkie
```
add user 'pinkie' with a home directory
```bash
```sh
sudo adduser -m -e 2017-04-25 temp
```
add expiry date to user
```bash
```sh
userdel maestro
```
delete maestro
```bash
```sh
userdel -r maestro
```
delete maestro and hir homefolder
```bash
```sh
groups
```
find which group you are in
```bash
```sh
id
```
same
```bash
```sh
id -Gn maestro
```
Find which groups maestro is in
```bash
```sh
deluser --remove-home maestro
```
delete user maestro
```bash
```sh
usermod -aG sudo maestro
```
Add user maestro to group sudo:
```bash
```sh
cat /etc/passwd
```
list users' passwords (and therefore users)
```bash
```sh
groupadd awesome
```
@@ -104,33 +104,33 @@ Passwords are stored in /etc/shadow.
There are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
```bash
```sh
passwd -l bin
```
Lock the user 'bin'.
```bash
```sh
more /etc/passwd | grep games
```
we find the name, password and user id of the user 'games'. I.e. the password is 'x', and the user id is '5'. The password is an impossible hash, so no input password could match.
```bash
```sh
groupdel learners | delete the group 'learners'
```
```bash
```sh
gpasswd -d pi games | remove user 'pi' from the group 'games'
```
```bash
```sh
id games
```
find the id number of group 'games' (60)
```bash
```sh
usermod -aG sudo maestro
```
@@ -156,7 +156,7 @@ Alternatively, change the shell in /etc/passwd.
Usermod also lets you change a user's username:
```bash
```sh
usermod -l henry mark
```
@@ -170,7 +170,7 @@ usermod -L henry
-G or -groups adds the user to other groups:
```bash
```sh
usermod -G sudo henry
```
@@ -186,13 +186,13 @@ In /etc/group, a group file may look like this:
We can use groupmod, like like usermod, e.g. to change a name:
```bash
```sh
groupmod -n frontoffice backoffice
```
Delte a group:
```bash
```sh
groupdel frontoffice
```
@@ -200,37 +200,37 @@ groupdel frontoffice
See list of logged on users.
```bash
```sh
w
```
See last logons:
```bash
```sh
last
```
or all logon attempts, including bad attempts:
```bash
```sh
lastb
```
List recently accessed files:
```bash
```sh
last -d
```
See files opened by steve
```bash
```sh
lsof -t -u steve
```
See files opened by anyone but steve
```bash
```sh
lsof -u ^steve
```
@@ -240,19 +240,19 @@ Some files can be executed by people as if they had super user permissions, and
Let's start with files executable by user:
```bash
```sh
sudo find / -type f -perm -g=s -ls
```
And then those executable by the group:
```bash
```sh
find / -type f -perm -g=s -ls
```
And finally, worrying files, executable by anyone as if sie were the owner:
```bash
```sh
find / -xdev \( -o -nogroup \) -print
```
@@ -260,7 +260,7 @@ Then have a look at resource usage per user.
# SGID
```bash
```sh
sudo chmod u+s process.sh
```

View File

@@ -11,14 +11,14 @@ This is extremely powerful.
If you ever want to automatically install something which persistently nags you with `do you want to do the thing? [y/N]?`, then you can just pipe `yes` into that program, and it will answer 'yes' to all questions.
```bash
```sh
yes | $INSTALL_SCRIPT_FILE.sh
```
This works best for disposable systems, like VMs or containers.
Try this on a live system, and you might find out that you should have read that message fully.
```bash
```sh
yes | yay
```