Enable the serial console for custom Linux VM image on Azure
For example: S0:12345:respawn:/sbin/agetty -L 115200 console vt102.
You may also need to spawn a getty on ttyS0 and this can be done with systemctl start serial-getty@ttyS0.service.
Just another WordPress site
for i in {1..20..3}; do
echo “Welcome $i”
done
example:
snoopy@srv02:~# for i in {1..20..3}; do echo "Welcome $i"; done
Welcome 1
Welcome 4
Welcome 7
Welcome 10
Welcome 13
Welcome 16
Welcome 19
snoopy@srv02:~#
screen -S SESSIONNAME
. When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for “screen -list” and “screen -r” actions.
If you already started a session and later decide to name it.
Enter to a command mode (Ctrl+a, :
) and then type sessionname SESSIONNAME
.
To allow user01 to copy any files as root from /from/directory/ to /to/directory/ add the following to /etc/sudors file:
user01 ALL = NOPASSWD: /bin/cp /from/directory/* /to/directory/
And this one is for the multi commands:
user01 ALL = NOPASSWD: /bin/cp /from/directory/* /to/directory/, /bin/rm -rv /to/directory/*, /bin/ls -la /to/direcotry/*
As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt. You will see a GRUB boot prompt – press “e” to edit the first boot option. Find the kernel line linux16
or linuxefi
or linux
(Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add init=/bin/sh
at the end of the line and then press CTRL-X to boot.
System will boot and you will see the root prompt. Type mount -rw -o remount /
and then passwd
to change the root password and then touch /.autorelabel
and then exec /sbin/init
In short:
init=/bin/sh
– In case of VMWare like KVM or VirtualBox use rb.break instead of inti=/bin/sh
# mount -o remount,rw /
# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel
# exec /sbin/init
It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug init=/bin/sh
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut
# Allow OpenVPN
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 1194 -j ACCEPT
iptables -A FORWARD -s 192.168.88.0/24 -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.88.0/24 -o venet0:0 -j MASQUERADE
# in OpenVZ/VServers you may need the following instead the lane above
iptables -t nat -A POSTROUTING -s 192.168.88.0/24 -j SNAT --to-source 198.50.149.196
After the upgrade Debian 7 to Debian 8 on OpenVZ platform on OVH the OpenVPN service stopped working. The problem was that the “TUN” device was missing, so the command below will temporary fix this problem.
root# mkdir -p /dev/net
root# mknod /dev/net/tun c 10 200
root# chmod 600 /dev/net/tun
Also you can add this to a script at start up.
Just run this script 🙂
find HR Operations| while read NAME; do stats=`stat --format "%n;%y;%s;%U" "$NAME"`; rightss=`rights -f "$NAME" show|grep -i "CN="|tr 'n' ' '`; echo "$stats;$rightss"; done > "HR_Operations.csv"
The filename and pathname lengths are limited; constants defined in linux/limits.h
#define NAME_MAX 255 /* # chars in a file name */
#define PATH_MAX 4096 /* # chars in a path name including nul */
nbfs1:~ # getconf NAME_MAX /
255
nbfs1:~ # getconf PATH_MAX /
4096
nbfs1:~ #
The simplest way to send a file as a mail attachment is shown by the following examples:
# uuencode snoopy1.jpeg snoopy1.jpeg | mail user@dump.4network.org
If user uses a current mail reader like Mozilla, Netscape Messenger or Microsoft Exchange, she/he will see a mail containing just one file attachment: the file “snoopy1.jpeg”.
This way we can include text, too:
# (cat mailtext; uuencode snoopy1.jpeg snoopy1.jpeg) | mail user@dump.4network.org
The file called “snoopy1.jpeg” again appears twice on the uuencode command line: the first time to specify the input file name, the second time for the remote extraction file name.
or
echo -e "text in line1 ntext in line2"| mail -s "Subject of an e-mail" -r "User1<user1@dump.4network.org>" -a "/tmp/abc.zip" name@domian.com