Custom Search

How to copy a long file name from thumb drive?

When copying files and directories from thumb drive or usb drive, we always dealing with windows file. There is no problem if you are using Ubuntu desktop because you just right-click the file, copy and paste it in your Linux. In Ubuntu server we are working in the command line terminal. To copy a long file name with white space need some creativity.

Here are some tips on how to copy longer file name with white space from thumb drive/usb drive in Linux command line terminal:

We need to add a backslash at the end of every words in the file name. Here is an example on how to copy longer file with white space:

kucing@ubuntu-server:/media/disk$ ls | grep Linux

Linux copy command tutorial.txt

Linux copy windows file.txt

Linux command copy file example01.txt

Type cp and the first word in the file name:

 kucing@ubuntu-server:/media/disk$ cp Linux

Pressing the tab key wouldn't help here. What you have to do is to put a backslash after the first word:

kucing@ubuntu-server:/media/disk$ cp Linux\ 

Press spacebar to put a white space and key in the second word:

kucing@ubuntu-server:/media/disk$ cp Linux\ copy\

Repeat steps above if you have a long file name.

kucing@ubuntu-server:/media/disk$ cp Linux\ copy\ windows\ file.txt /home/tutorials/

That's it. A simple thing but can cause a headache for a Linux beginner.

Add another admin in Ubuntu server

There are several reasons why we need extra admin user in Ubuntu server. One of the reason perhaps it's an account for your boss. Yes, in several occasions, your boss needs root privilege to do whatever 'his job' that need to be done.

Well, whatever your reason is, here is how you can add another user in the admin group in Ubuntu server:

Login into Ubuntu server using user in admin group username(user with root privilege). This is the user that can use 'sudo' command, or the default user you created during Ubuntu server installation.

In the command prompt, type:

luzar@ubuntu:~$ sudo adduser jimi admin
Adding user `jimi' to group `admin' ...
Adding user jimi to group admin

Replace jimi with a username that you want to add to the admin group. Let's check the /etc/group file to see whether the user has been added to the admin group:

luzar@ubuntu:~$ cat /etc/group

Here is the result:


That's it. Now jimi can run whatever commands that needs root privilege by using sudo command. He has the same power as you now.

How to check Ubuntu server Linux version

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

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
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?

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:

usermod - modify a user account

usermod [options] LOGIN

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:

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

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

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

That's all.

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

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

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:

That's all.