Last active
October 15, 2020 15:56
-
-
Save 00sapo/ea2ddd85b38a085cb6399d41f41a2a27 to your computer and use it in GitHub Desktop.
Useful shell commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# disabling arp to become an nmap ghost (but you can't use nmap anymore) | |
ip link set dev wlp2s0 arp off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert -density 150 input.pdf -colorspace gray -linear-stretch 3.5%x10% -blur 0x0.5 -attenuate 0.25 +noise Gaussian output.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!
- Export the list of packages installed through
pip
:
>>> pip freeze > packages.txt
- Launch this command: it will re-download and install through
pacman
packages installed frompip
that are not marked asinstalled
in thepacman
database.
>>> for i in $(awk -F "==" '{print $1}' packages.txt); do sudo pacman -S --needed --force --noconfirm python-$i; done
-
You can do the same with
python2
by just adding2
afterpython
andpip
in the above commands. -
Since now on, just use
pacman
, notpip
. You can usepip
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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