
One of the biggest confusion for a former Microsoft Windows user would be use of command line, or shell utilities. How to list directory in Linux? How to copy file? How to clear screen? Those are amongst the top questions here.
In this article, we will try to give you narrow list of most used cross-system commands, so that you won’t be lost next time you open your terminal window.
To open command line, or shell, in Ubuntu go to Applications > Accessories > Terminal.

In open terminal window, you will see command line prompt.
It is formatted as username @ hostname:(directory name)$ instead of C:\> which you could observe in Microsoft Windows.
Please, note that unlike Microsoft Windows, Ubuntu and all other Linux distributives (or distros) use slash (‘/’) in for directory paths, and NOT backslash (‘\’).
Generally all commands are executed with ‘-‘ switch (eg. ‘ls -l’) instead of ‘/’ (eg. ‘dir /b’) switch.
In addition, to get help on desired command, you should append ‘-- help’ instead of ‘/?’ as you would do in Microsoft Windows.
To change directory, you may use the same ‘cd’ command as in Microsoft Windows, except you should type the path with slashes. For example:
NOTE: You may NOT use ‘chdir’ command, as it will NOT work.
To list directory content use ‘ls’ command instead of ‘dir’:
To create a directory, you may use ‘mkdir’, but you can’t use ‘md’:
To remove a a directory, you may use ‘rm’ instead of ‘rd’:
To move a directory, you should use ‘mv’ instead of ‘move:
There is quite significant difference between file attributes on Linux system, and hence Ubuntu, and file attributes on Windows system. Main difference is that on Linux attributes are playing access control role, while on Windows they are mostly additives.
So, if on Windows we have 4 attributes:
Plus date and time of modification, on Linux we have:
Now those last 3 attributes ‘rwx’ – Read, Write and Execute – are present for 3 roles: user himself, group user is belonging to and others.
So, when you list files with ‘ls -la’ command, you see something like this:
-rwxr-xr-- 1 root 1153 2011-04-06 00:43 .bash_profile
You should understand it like that:
Now to change these attributes, you should use ‘chmod’ command, instead of ‘attrib’, as follows:
chmod [role: uga][+/-/=][mode: rwx]
Where:
So, user’s group to write to file, one can issue command like this:
chmod g+w .bash_profile – adds writing permission to file for file owner’s group users
And to remove read permissions from everyone, but user and his group, one could issue command like that:
chmod a-r .bash_profile – removes reading permission from all who is not user nor in his group
To copy file in Ubuntu, one should issue ‘cp’ command instead of ‘copy’ as he would do in Windows:
cp .bash_profile /var/tmp – copies .bash_profile to directory at /var/tmp
To remove file in Ubuntu, one should use ‘rm’ command instead of ‘del’ as he would do in Windows:
rm /var/tmp/.bash_profile – removes .bash_profile file at /var/tmp
To view contents of file, you should use ‘cat’ command instead of ‘type’:
cat /usr/share/common-licenses/GPL – will display GPL file from /usr/share/common-licenses folder folder (identical to ‘type c:\windows\system32\license.rtf’)
To compare two files, you should use ‘cmp’ command instead of ‘fc’, and append ‘-l’ option, if you want it to display all differences:
cmp -l /usr/share/common-licenses/GPL-2 /usr/share/common-licenses/GPL-3 – will display byte-by-byte comparison of two files, which in this case are GPL license files version 2 and 3. Output is produced as follows:
[file offset at which the difference was found] [byte from file #1] [byte from file #2]
17987 12 40 – tells us that at offset 17987, in file one we have byte with ASCII decimal value of 12, while in file two – with ASCII decimal value of 40.
To edit file’s content, you should use ‘nano’ command instead of ‘edit’:
nano .bash_profile – opens .bash_profile in nano editor (like ‘edit .bash_profile’)
To attach disk to your system (like mounting removable media, network drive or disk images), you must issue command:
mount -t [file system type] [descriptor] [directory-to-mount-to]
Where file system type is one of:
So, if you want, for example, to mount CD-Rom manually, you should issue command like:
mount -t udf /dev/cdrom /mnt/cdrom – this will attach loaded disk’s file system to /mnt/cdrom directory.
NOTE: /mnt/cdrom is not created by default, so if you do mount it, create it first (‘mkdir /mnt/cdrom’)
To detach disk from your system, issue command:
umount [path-to-mounted directory OR path to device descriptor]
For example:
umount /dev/cdrom – detaches CDRom file system and releases lock from eject button.
NOTE: In case it fails to detach, you can add ‘-f’ switch to enforce un-mounting (‘umount -f /dev/cdrom’).
To display list of currently active mounts, issue ‘mount’ command with no options.
To display partition table, Linux have ‘fdisk’ utility (as in older Windows versions), issue command:
sudo fdisk -l [device descriptor, such as] /dev/sda – will list partition table for /dev/sda
If disk doesn’t have partition table, you will see only disk information and message similar to ‘Disk /dev/sda1 doesn’t contain a valid partition table’.
NOTE: We appended ‘sudo’ command in front of ‘fdisk’, which enables us to perform administrative actions. See next section for detailed explanation.
mkfs -t [file system type] [descriptor]
Where file system type is one of:
For example:
mkfs -t ext4 /dev/sdb1 – will format device at /dev/sdb1 with EXT4 file system.
If you need to perform any changes that affect the system as whole, you will need to activate administrator mode. This can be done in two ways:
NOTE: Second way is strongly discouraged amongst Linux community, as considered to create potential security breach. While it is true that work in ‘god mode’ is NOT ideally secure, it is true as well, that sometimes you may just need it.
This concludes our – Ubuntu Command Line for Windows Users – article. We hope you enjoyed reading it as much as we enjoyed bringing it to you.
Stay tuned for more interesting articles, and please, leave your comments below, so that we could improve material we bringing to you.
Add new comment