Skip to content

Instantly share code, notes, and snippets.

@00sapo
Last active October 15, 2020 15:56
Show Gist options
  • Save 00sapo/ea2ddd85b38a085cb6399d41f41a2a27 to your computer and use it in GitHub Desktop.
Save 00sapo/ea2ddd85b38a085cb6399d41f41a2a27 to your computer and use it in GitHub Desktop.
Useful shell commands
# disabling arp to become an nmap ghost (but you can't use nmap anymore)
ip link set dev wlp2s0 arp off
convert -density 150 input.pdf -colorspace gray -linear-stretch 3.5%x10% -blur 0x0.5 -attenuate 0.25 +noise Gaussian output.pdf
rm /var/lib/pacman/db.lck

WARNING: this answer uses the --force option of the pacman command. You should use it if and only if you understand what you are doing!

  1. Export the list of packages installed through pip:

>>> pip freeze > packages.txt

  1. Launch this command: it will re-download and install through pacman packages installed from pip that are not marked as installed in the pacman database.

>>> for i in $(awk -F "==" '{print $1}' packages.txt); do sudo pacman -S --needed --force --noconfirm python-$i; done

  1. You can do the same with python2 by just adding 2 afterpython and pip in the above commands.

  2. Since now on, just use pacman, not pip. You can use pip to upgrade/downgrade to a particular version a package, if needed.

If you like, you can also use a script version:

#!/bin/sh
pip freeze > packages.txt
for i in $(awk -F "==" '{print $1}' packages.txt)
do
     sudo pacman -S --needed --force --noconfirm python-$i
done

Save it to file, give execution permission to that file and run.

[Unit]
Description=Portspoof
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/portspoof -c /etc/portspoof/portspoof.conf -s /etc/portspoof/portspoof_signatures
Restart=on-abort
StandardOutput=journal
ProtectSystem=strict
ProtectHome=true
[Install]
Alias=Portspoof
# also configure iptables:
# sudo iptables -t nat -I PREROUTING --src 0/0 --dst 192.168.1.27 -p tcp --dport 1:65535 -j REDIRECT --to-ports 4444
# sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 1:65535 -j REDIRECT --to-ports 4444
# sudo iptables-save -f /etc/iptables/iptables.rules
Ok, there is what I've done
First, my goal was to reduce my / (ROOT) partition in order to add another one on my disk.
From running session once everything cleaned and backuped:
init 1
My desktop go away and I'm now on Linux console...
...
Give root password for maintenance or press CTRL+D to continue
TheRootPassword_SomethingLike1234
Now, trying to mount / in read-only mode:
mount -o remount,ro /
mount: / is busy
Ok, from now, I'm in theorically single-user mode, but ps ax show a lot of other process!!
Killing them all tis not really possible, or dangerous... ( kill 1 is forbiden... I don't have time to play psdoom :-)
The only thing I can do is a System Request, for this, I know two ways: (see Documentation/sysrq.txt file in kernel docs):
first using magic SysRq key keyboard kernel trap:
hold down AltGr, then maintain then pressed,
hit PrtScn just once, but don't release AltGr,
hit s just once, this will send Emergency sync request to kernel and
hit u, this will send Umount all request, this will remount all mounted filesystems read-only,
then release AltGr
Or by command line:
echo s >/proc/sysrq-trigger
echo u >/proc/sysrq-trigger
Then now, I could
fsck -fC0 /dev/mapper/MyDisk-ROOT
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment