If you want to add an user to your Ubuntu Linux machine here is what you need to do. Login as root (or use sudo) and then run (as root):
useradd -d /home/john -m john passwd john usermod -aG sudo john
If you are not root run:
sudo useradd -d /home/john -m john sudo passwd john sudo usermod -aG sudo john
In our example john is the user we want to add. Last command (usermod) will allow our user to run root commands via sudo.
If you are using Ubuntu Linux you’ve logged in as an user. If you want to become root so you won’t have to input sudo on every command you run, here’s what you need to do:
sudo su -
which is probably what you really want. su – will invoke a login shell after switching the user. Just running su with no parameters will just switch the user (keeping the old shell and environment variables).
You can also run:
Then you get the root prompt and you will be able to run any command as root.
Let’s say you’ve booted with Live Ubuntu CD/DVD and you want to change the password of your user which is called ubuntu on Live Ubuntu CD/DVD. If you run:
you might get an error like:
You must choose a longer password
Bad: new password is too simple.
You can bypass those checks by running passwd as a root with sudo:
That way you will be allowed to enter short or too simple passwords which sometimes you need for testing purposes. Of course you will not use such passwords on machines connected to the internet but maybe only on test machines, maybe in virtualized environments.
If you want to install VirtualBox Guest Additions on Ubuntu Linux Guest here what you need to do.
First go to VirtualBox -> Devices and click on Insert Guest Additions CD Image.
From the terminal look where the image is mounted. Usually it is under:
where username is your username used to login to your machine.
Then we need to install some packages:
sudo apt-get update sudo apt-get install build-essential linux-headers-$(uname -r)
Then we run the script from the CD image:
cd /mnt/username/VBOXADDITIONS_5.0.18_10667 sudo ./VBoxLinuxAdditions.run
You need to run this script after every kernel update.
So you’ve just installed Ubuntu 16.04, you’ve configured networking and it works properly but when you want to install Midnight Commander (or other package) you get an error:
apt-get install mc is not available
To fix the problem run first apt-get update command:
sudo apt-get update
Then try to install mc:
sudo apt-get install mc
Of course there could be other reasons (like your /etc/apt/sources.list file missing or containing wrong links to package repos) but on a default Ubuntu installation this could fix the problem).
If you want to be able to move your mouse cursor outside the VirtualBox CentOS Guest window without pressing a key and also automatically scale CentOS Guest window you need to install VirtualBox Guest Aditions on your CentOS Guest.
In order to do that run:
yum install dkms yum install kernel-devel
Then add the cd from VirtualBox (Devices -> Insert Guest Aditions CD image). If you are using a window manager (like for example Mate) the iso will be mounted in /run/media where we can find the install script:
cd /run/media/root/VBOXADDITIONS_5.0.18_106667/ ./VBoxLinuxAdditions.run
Let’s say we’ve installed a minimal version of CentOS Linux 7 from minimal cd iso and now we want to install Mate desktop. In order to do that we will need to install the epel repository, then to install Xorg server and then to add Mate from epel.
First we want to update our system to make sure we have latest version:
yum check-update yum update
Then let’s proceed with installation:
yum groups mark convert yum install epel-release yum groups install "X Window System" yum groups install "Mate Desktop" yum install dkms
Then we want to enable graphical desktop at boot:
systemctl set-default graphical.target
If you want to see the IP of your network card use the ip command:
ip addr show
If you’ve installed CentOS from minmal cd image then the ifconfig command is not installed. If you really want the ifconfig command you need to install net-tools:
yum install net-tools
This is working, of course, if your network is properly configured. And don’t think to add net-tools package from CentOS 7 minimal install since it is not there.
Some will say that ifconfig, netstat, arp and route commands have been deprecated for some years now and have been removed from the default CentOS 7 install.
To mount a CD in CentOS 7 Linux run mount:
mount /dev/cdrom /mnt
If you try to run ifconfig command on CentOS Linux 7 and you find out you do not have ifconfig installed then to be able to run it you must install net-tools package:
yum install net-tools
This will work of course if you have the networking configured. Or you can install it from CD media.