If you are a Windows user before, there is no ver command in Linux that can be used to check the version of Ubuntu server. In Linux or Ubuntu server specifically, there are many commands that can be used to check operating system version.
The first command that can be used to check Ubuntu server version is, as Ubuntu suggest, the lsb_release -a command. Here is the example:
luzar@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.10
Release: 8.10
Codename: intrepid
luzar@ubuntu:~$
Second command that we can use to check Linux version is cat /proc/version. See example below:
luzar@ubuntu:~$ cat /proc/version
Linux version 2.6.27-14-server (buildd@palmer) (gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) ) #1 SMP Wed Apr 15 19:44:38 UTC 2009
luzar@ubuntu:~$
We can also view all information about Ubuntu server using uname -a option:
luzar@ubuntu:~$ uname -a
Linux ubuntu 2.6.27-14-server #1 SMP Wed Apr 15 19:44:38 UTC 2009 i686 GNU/Linux
There you go. We've got more information than what we ask for. Well, that's good, isn't it?
Ubuntu server installation, hard disk partition, basic commands, network configurations, Ubuntu administration and security guide for a beginner.
Custom Search
How to add user to a group in Linux operating system
We can assign user to a group during adding a new user account. But how do we add existing user to a group? This tutorial is a guide on how to add user to a new group. The right Linux command for the job is the usermod command.
This is some information about Linux usermod command from manual page:
As you can see, the Linux usermod command can be used to modify a user account. However in this tutorial, we'll only use usermod command to add user to a new group. For this example, we'll create a new group to practice. Use the groupadd command to create a new group:
luzar@ubuntu:~$ groupadd programmer
groupadd: unable to lock group file
luzar@ubuntu:~$ sudo groupadd programmer
[sudo] password for luzar:
luzar@ubuntu:~$
Don't forget to use sudo command in Ubuntu, else you'll get the groupadd: unable to lock group file error as in the example above. Check whether the programmer group has been created in /etc/group file:
luzar@ubuntu:~$ less /etc/group | grep programmer
programmer:x:1001:
luzar@ubuntu:~$
Next, we are going to add user to a new group. For this example, we are going to add a user called luzar to the programmer group. Below are step by step instructions.
Use usermod -G option to add user to a new group:
luzar@ubuntu:~# sudo usermod -G programmer luzar
Use Linux groups command to check whether the programmer group has been added to luzar's group:
luzar@ubuntu:~# groups luzar
luzar : users programmer
luzar@ubuntu:~#
As you can see, the user luzar now has programmer as a second group. We can also check /etc/group to verify user currently in the programmer group:
luzar@ubuntu:~$ less /etc/group | grep programmer
programmer:x:1001:luzar
luzar@ubuntu:~$
That's all.
This is some information about Linux usermod command from manual page:
NAME
usermod - modify a user account
SYNOPSIS
usermod [options] LOGIN
DESCRIPTION
The usermod command modifies the system account files to reflect the
changes that are specified on the command line.
As you can see, the Linux usermod command can be used to modify a user account. However in this tutorial, we'll only use usermod command to add user to a new group. For this example, we'll create a new group to practice. Use the groupadd command to create a new group:
luzar@ubuntu:~$ groupadd programmer
groupadd: unable to lock group file
luzar@ubuntu:~$ sudo groupadd programmer
[sudo] password for luzar:
luzar@ubuntu:~$
Don't forget to use sudo command in Ubuntu, else you'll get the groupadd: unable to lock group file error as in the example above. Check whether the programmer group has been created in /etc/group file:
luzar@ubuntu:~$ less /etc/group | grep programmer
programmer:x:1001:
luzar@ubuntu:~$
Next, we are going to add user to a new group. For this example, we are going to add a user called luzar to the programmer group. Below are step by step instructions.
Use usermod -G option to add user to a new group:
luzar@ubuntu:~# sudo usermod -G programmer luzar
Use Linux groups command to check whether the programmer group has been added to luzar's group:
luzar@ubuntu:~# groups luzar
luzar : users programmer
luzar@ubuntu:~#
As you can see, the user luzar now has programmer as a second group. We can also check /etc/group to verify user currently in the programmer group:
luzar@ubuntu:~$ less /etc/group | grep programmer
programmer:x:1001:luzar
luzar@ubuntu:~$
That's all.
Labels:
Linux administration,
Linux howto,
Linux tips
How to mount external hard drive in Ubuntu server
This is a step by step guide on how to mount external hard drive in Linux for Ubuntu server beginner and Linux beginner in general. The guide includes error happened during the process to show how it to mount device in real situation.
Mount external hard drive in Ubuntu server
Insert external hard drive usb connector into the Ubuntu server usb port. Ubuntu server automatically detect the external hard drive as a usb device. Below is the example screenshot when ubuntu detected the external hard drive:
We can see that the external hard drive has been detected as sdb. That is the name of the external hard drive to use when we are going to mount the device. We can check the device in /proc/scsi/scsi file. To do that, issue the command as in the example below:
luzar@ubuntu:~$ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: Generic Model: USB Disk Rev: 9.02
Type: Direct-Access ANSI SCSI revision: 02
luzar@ubuntu:~$
Create a proper directory in Ubuntu server to mount the external hard drive. In this example, we create a directory named extdisk in /mnt directory:
luzar@ubuntu:~$ sudo mkdir /mnt/extdisk
[sudo] password for luzar:
luzar@ubuntu:~$ ls /mnt/
dvd extdisk usb win
Now we can mount the external hard drive with Linux mount command:
luzar@ubuntu:~$ sudo mount /dev/sdb /mnt/extdisk/
mount: you must specify the filesystem type
The external hard drive cannot be mounted. This happened when we mount a windows formatted external hard drive. We must specify the filesystem. Windows filesystem format is known as nsfs-3g in Linux. So we mount the external hard drive again with the complete command:
luzar@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb /mnt/extdisk/
NTFS signature is missing.
Failed to mount '/dev/sdb': Invalid argument
The device '/dev/sdb' doesn't have a valid NTFS.
Maybe you selected the wrong device? Or the whole disk instead of a
partition (e.g. /dev/hda, not /dev/hda1)? Or the other way around?
We still cannot mount the external hard drive. Again, we mount the external hard drive but this we change the device name from /dev/sdb to /dev/sdb1 as suggested by Ubuntu message above.
luzar@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb1 /mnt/extdisk/
luzar@ubuntu:~$ ls /mnt/extdisk/
ghost dell170l ghost mimos RECYCLER System Volume Information
luzar@ubuntu:~$
We successfully mounted the external hard drive this time. Now that the external drive has been mounted, we can use it as other directory in Ubuntu.
To unmount the external hard drive, we can use the Linux umount command like in the example below:
luzar@ubuntu:~$ sudo umount /mnt/extdisk/
[sudo] password for luzar:
luzar@ubuntu:~$
That's all.
Mount external hard drive in Ubuntu server
Insert external hard drive usb connector into the Ubuntu server usb port. Ubuntu server automatically detect the external hard drive as a usb device. Below is the example screenshot when ubuntu detected the external hard drive:
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: Generic Model: USB Disk Rev: 9.02
Type: Direct-Access ANSI SCSI revision: 02
luzar@ubuntu:~$
Create a proper directory in Ubuntu server to mount the external hard drive. In this example, we create a directory named extdisk in /mnt directory:
luzar@ubuntu:~$ sudo mkdir /mnt/extdisk
[sudo] password for luzar:
luzar@ubuntu:~$ ls /mnt/
dvd extdisk usb win
Now we can mount the external hard drive with Linux mount command:
luzar@ubuntu:~$ sudo mount /dev/sdb /mnt/extdisk/
mount: you must specify the filesystem type
The external hard drive cannot be mounted. This happened when we mount a windows formatted external hard drive. We must specify the filesystem. Windows filesystem format is known as nsfs-3g in Linux. So we mount the external hard drive again with the complete command:
luzar@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb /mnt/extdisk/
NTFS signature is missing.
Failed to mount '/dev/sdb': Invalid argument
The device '/dev/sdb' doesn't have a valid NTFS.
Maybe you selected the wrong device? Or the whole disk instead of a
partition (e.g. /dev/hda, not /dev/hda1)? Or the other way around?
We still cannot mount the external hard drive. Again, we mount the external hard drive but this we change the device name from /dev/sdb to /dev/sdb1 as suggested by Ubuntu message above.
luzar@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb1 /mnt/extdisk/
luzar@ubuntu:~$ ls /mnt/extdisk/
ghost dell170l ghost mimos RECYCLER System Volume Information
luzar@ubuntu:~$
We successfully mounted the external hard drive this time. Now that the external drive has been mounted, we can use it as other directory in Ubuntu.
To unmount the external hard drive, we can use the Linux umount command like in the example below:
luzar@ubuntu:~$ sudo umount /mnt/extdisk/
[sudo] password for luzar:
luzar@ubuntu:~$
That's all.
Labels:
Linux howto,
Linux tips
How to power off Ubuntu server with Linux shutdown command
The Linux shutdown command has several options that you can use to bring down the Linux system. In the previous post, we've seen how to reboot Ubuntu server with shutdown command. In this post, we are going to use the Linux shutdown command again. This time is to power off the Ubuntu server.
There are several options available with shutdown command that can be used to power off Linux system. One example is -h option, which means to halt the system after it has been brought down. We can add other things such as a comment message when invoking shutdown -h command. As you can see from the example of Ubuntu restart post before, we have to specify a time argument after the shutdown option so the system know when to shutdown the system. Here are some examples on how to power off Ubuntu server using shutdown command with other things that you can do:
1) Using Linux shutdown command with -h option example:
The example above show a basic shutdown command used to power off Ubuntu server. We used '-h' option and a time argument 'now' which means to bring down the system after we press enter.
2) Using Linux shutdown command -p option example:
The example above shows the '-P' option is added after the '-h' option. The -P option means 'power off'. When -P is used after -h option, it means we tell the system to power off after the system halt. Also this time we used +1 in the time argument. That means we want to bring down the system after 1 minute.
3) If you have to warn all your users, you can write a message after the time argument. See the example below:
If you want to cancel shutdown after invoked the command, you can press Ctrl+C combination keys. That will work if you do not use the 'now' time argument. If you just want to warn users to log out and prevent other user to login without actually bring the system down, you can use '-k' option.
That's all.
There are several options available with shutdown command that can be used to power off Linux system. One example is -h option, which means to halt the system after it has been brought down. We can add other things such as a comment message when invoking shutdown -h command. As you can see from the example of Ubuntu restart post before, we have to specify a time argument after the shutdown option so the system know when to shutdown the system. Here are some examples on how to power off Ubuntu server using shutdown command with other things that you can do:
1) Using Linux shutdown command with -h option example:
luzar@ubuntu:~$ sudo shutdown -h now
[sudo] password for luzar:
Broadcast message from luzar@ubuntu
(/dev/pts/0) at 11:32 ...
The system is going down for halt NOW!
The example above show a basic shutdown command used to power off Ubuntu server. We used '-h' option and a time argument 'now' which means to bring down the system after we press enter.
2) Using Linux shutdown command -p option example:
luzar@ubuntu:~$ sudo shutdown -h -P +1
Broadcast message from luzar@ubuntu
(/dev/pts/0) at 11:47 ...
The system is going down for power off IN ONE MINUTE!
The example above shows the '-P' option is added after the '-h' option. The -P option means 'power off'. When -P is used after -h option, it means we tell the system to power off after the system halt. Also this time we used +1 in the time argument. That means we want to bring down the system after 1 minute.
3) If you have to warn all your users, you can write a message after the time argument. See the example below:
luzar@ubuntu:~$ sudo shutdown -h -P +3 Please save your work now! Broadcast message from luzar@ubuntu (/dev/pts/0) at 11:57 ... The system is going down for power off in 3 minutes! Please save your work now! shutdown: Shutdown cancelled
If you want to cancel shutdown after invoked the command, you can press Ctrl+C combination keys. That will work if you do not use the 'now' time argument. If you just want to warn users to log out and prevent other user to login without actually bring the system down, you can use '-k' option.
luzar@ubuntu:~$ sudo shutdown -k +3 Please save your work now!
Broadcast message from luzar@ubuntu
(/dev/pts/0) at 12:11 ...
The system is going down for maintenance in 3 minutes!
Please save your work now!
luzar@ubuntu:~$
That's all.
Labels:
Linux administration,
Linux basic commands
Restart Ubuntu server
There are many commands that can be used to restart Ubuntu Server. We are going to look at some of them that I remember. The first one is the reboot command. In Linux reboot means restart. To use the reboot command, invoke reboot at the command line terminal. You must have root privilege, so add sudo before reboot.
Restart Ubuntu server with reboot command example:
The second command that can be used to restart Ubuntu server is the shutdown command. In Ubuntu, you can use shutdown command to bring down the system to restart or to power off the system. That depends on the option given with shutdown command. To restart Ubuntu system with shutdown command, use shutdown with -r option and provide time to shutdown the system. See the example below.
Restart Ubuntu server with shutdown command example:
Press Ctrl+c to cancel restart.
You can use shutdown command to restart the system on the spot using now as the time argument. See an example below:
That's the command that you can used to restart Ubuntu server system if you have to.
Restart Ubuntu server with reboot command example:
| luzar@ubuntu:~$ sudo reboot [sudo] password for luzar: |
The second command that can be used to restart Ubuntu server is the shutdown command. In Ubuntu, you can use shutdown command to bring down the system to restart or to power off the system. That depends on the option given with shutdown command. To restart Ubuntu system with shutdown command, use shutdown with -r option and provide time to shutdown the system. See the example below.
Restart Ubuntu server with shutdown command example:
| luzar@ubuntu:~$ sudo shutdown -r 18:00 [sudo] password for luzar: Broadcast message from luzar@ubuntu (/dev/pts/0) at 16:24 ... The system is going down for reboot in 96 minutes! Broadcast message from luzar@ubuntu (/dev/pts/0) at 16:30 ... The system is going down for reboot in 90 minutes! |
Press Ctrl+c to cancel restart.
| The system is going down for reboot in 90 minutes! shutdown: Shutdown cancelled luzar@ubuntu:~$ |
You can use shutdown command to restart the system on the spot using now as the time argument. See an example below:
| luzar@ubuntu:~$ sudo shutdown -r now [sudo] password for luzar: Broadcast message from luzar@ubuntu (/dev/pts/0) at 16:44 ... The system is going down for reboot NOW! |
That's the command that you can used to restart Ubuntu server system if you have to.
Labels:
Ubuntu Linux basic
Subscribe to:
Posts (Atom)
