Linux Tips
This is all about Linux tips that will be constantly updated.
Howto let Virtualbox boot from ISO
Create a new machine, then under Settings > Storage, there are 2 controllers (IDE and SATA), pick IDE one and click the Drive Icon there and could “Add a CD/DVD device”, then navigate to the iso file and save those settings.
Set the boot option to begin with CD/DVD, so your machine can take off.
Howto get USB back after dd
You can type dd if=/iso_file of=/dev/sdx bs=4M && sync
to burn an image into USB stick, hereby howto reverse it:
-
Zero its first 512 bytes:
# dd count=1 bs=512 if=/dev/zero of=/dev/sdx && sync
-
Then install dosfstools and FAT32 and run:
# cfdisk /dev/sdx
# mkfs.vfat -F32 /dev/sdx1
# dosfslabel /dev/sdx1 The_Label_U_Like
Howto ssh ubuntu in VirtualBox
If you have a Linux machine running in Virtualbox, no matter your host is Linux or not, you can login to the guest by ssh without password.
- Shutdown the Virtualbox guest
- On the Virtualbox go to File -> Preferences -> Network -> Host-only Networks add one
- Configure the guest, Settings -> Network -> Adapter 2, Enable Network Adapter, pick Host-only Adapter for Attached to
- Edit the /etc/network/interfaces file and add following block:
autho eth1
iface eth1 inet static
address 192.168.56.110
netmask 255.255.255.0
- Then restart the networking using command
/etc/init.d/networking restart
- Install openssh-server
apt-get install openssh-server
and set password for rootsudo passwd root
-
Now restart the Virtualbox guest
- Edit host’s /etc/hosts,
sudo vim /etc/hosts
and add a line 192.168.56.110 guest
The next stage is about ssh login with no need of password by using RSA key
- On the host machine, generate RSA key by
ssh-keygen -t rsa
- Copy that public key onto guest machine per
scp ~/.ssh/id_rsa.pub You_User_Name@guest:
## Don’t forget the “:” in the end - Then login
ssh Your_User_Name@guest
cat id_rsa.pub >> ~/.ssh/authorized_keys
- Exit the ssh session and take a try of the new world!!
systemD and boot time
sudo systemd-analyze blame
will show you which service takes the longest time, if it’s about journal then you can remove all files within /var/log/journal/ and limit the usage by editing SystemMaxUse=40M
of sudo vim /etc/systemd/journald.conf
.