Your first boot

From Computer Science

Guides> linux > Your first boot


Getting Started

Select your virtual machine from the list on the left.

Click the green "Start" arrow.

Watch the messages fly by.

After a few seconds, you should see a prompt like this:

Arch Linux 5.4.7-arch1-1-ARCH (tty1)

middlinux login:

(If you installed Linux yourself, "middlinux" will be replaced with whatever hostname you chose.)

There is currently no user account for you, so (*this time only*) log in as the generic administrative user, "root". If you used the prebuilt image, the password is "password" (we'll change it in a few minutes - nothing will appear as you type the password. This is a feature, not a bug: somebody behind you cannot see how long your password is! Type the password and it will work.); if you installed it yourself, the password is whatever you set it to be during install.

(NB: the user "root" has complete, unfettered access to the entire machine. This means that if you're logged in as root and issue an ill-advised or mistyped command, you could really hose your system. Unless you have an extremely good reason, you should never log in as root. Instead, use the `sudo` program, which allows you to execute a program with temporarily elevated privileges.)

Upon successfully logging in, you should be presented with a shell prompt, indicating that the virtual machine is awaiting input:

[root@middlinux ~]#

Add a user

Since you are going to never log in directly as root, you need to create a user account you *will* use. In the following, replace "pete" with a username of your choice (as with the hostname, limit it to lowercase letters, numbers, and the underscore). Leave "wheel" as it is: this, in combination with the `sudo` program, is what will allow you to run a program with temporary administrator rights. Use the `id` program to verify afterwards. Use the `passwd` program to set the new user's password (note that it won't even print asterisks to let you know you're typing).

[root@middlinux ~]# useradd -m -G wheel pete
[root@middlinux ~]# id pete
uid=1000(pete) gid=1000(pete) groups=1000(pete),998(wheel)
[root@middlinux ~]# passwd pete
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Assuming this all works, log out by running `exit` and then attempt to log in as the newly-created user. Your prompt should now look similar to this:

[pete@middlinux ~]$

The "$" instead of the "#" indicates a user shell rather than a root shell.


Verify sudo works, and change root password if necessary

You will need to be able to run commands as root (ie, administrator) to, eg, install new software. The `sudo` program has been installed and configured, which allows you to temporarily take on root privileges to execute a specific command. You can verify it works by running the following command:

[pete@middlinux ~]$ sudo su

It will print a warning and prompt you for *your* password (ie, verifying that you are you, because the `sudo` configuration file says that you are allowed to run `sudo`), and then it should show a root shell prompt:

[root@middlinux ~]#

If you used the prebuilt install image, now is a good time to change the root password to something only you know:

[root@middlinux ~]# passwd

Note that nothing will be shown as you're typing (not even asterisks)!

Share a folder with the host system

You should not run this step as root!

Sometime you might want to be able to share files back and forth between the host (whatever machine you are running virtual box on) and the guest (Linux).

One way to achieve this is by sharing a folder between the two environment.

Here is an example on how to do that using a Mac as a host.

Open the settings for the Linux machine you have just created and choose the Shared Folders tab.

test

Click on the + icon to the right to add a new folder.

test

Enter the desired information:

test

Folder Path: Here is where you can select the folder on your host machine that you would like to share. You can click on other and browse for the folder you want to select.

Folder Name: This is the name you want to give to this folder (this is used by virtual box when it is listing the shared folder, it is not the name that will appear in your guest machine).

Read-only Select this if you want your guest to only have read access to the folder.

Auto-mount Select this if you want your guest to automatically use this folder every time you start the guest.

Mount point: This is the location in your guest where you want the folder to appear. Your home directory on the guest is at /home/username (where username is the user name you have selected in the add a user step. In the example, I want the folder to show up as cs202 in my home directory.

Make Permanent Select this to preserve this folder also when you restart your guest.

Now you can save your settings and restart your machine.

Once you log in using your username, you should be able to verify that the folder is indeed available. If you try to change directory to that folder, you will get a Permission denied error.

test

If you look at the ownership of the folder (using the ls -l) command, you can see that the directory is onwed by the user root and group vboxfs and you are not root and you don't belong to the vboxfs group so... no soup for you!

To fix this issue, the best way is to make you part of the vboxfs group and, to do that, you need to edit a file as root!

Type the following command:

[avaccari@middlinux ~]$ sudo vim /etc/group

You might be asked to enter your password. (If Linux complains that "sudo: vim: command not found", you might have to install vim. Check the Care and feeding page).

A file should open up and look something like this:

test

Scroll down with the arrow keys until you find the vboxfs:x:109: entry and modify it to add your username after the column.

To edit using vim:

  • move to the line where vboxfs:x:109: is located
  • push shift+a (this should bring you at the end of the line in insert mode)
  • type your username
  • push esc to exit insert mode
  • type the column : to enter command mode (this should show a column at the bottom of the screen)
  • type wq and then enter to save the file and quit

You should see something similar to this:

test

Restart your guest and you should now be able to use your folder from both host and guest.

Get graphical

BEFORE RUNNING THIS STEP - MAKE SURE YOU ARE NOT LOGGED INTO ROOT

You can now enter the graphical environment, XFCE:

DO NOT RUN XFCE AS ROOT


[pete@middlinux ~]$ startxfce4

The first time you run XFCE, it will ask if you want to use a default config or just one empty panel. I would recommend the former until you're more comfortable tweaking settings to your taste. To exit from the graphical environment, click your username in the top right and select "Log Out".

Congratulations

You're done. Now there are just a couple things you *need* to know before you start exploring (like, you know, a text editor).