I personally like to work on Linux operating system(s)(OS). I’m using Ubuntu which is one of the famous Linux flavour operating system.See the list of Linux distributions
This post is specifically on Ubuntu OS,one of the Linux operating system for beginners
Let’s start with Ubuntu installation. There are 2 types of installation.
There is pre-requisite for Ubuntu installation is you need bootable flashdrive or DVD. I prefer flashdrive.
- You can download latest version of Ubuntu desktop OS by clicking on this link. This is in ISO format
- You need bootable flash drive or DVD. If you are using windows then you can install software called Universal USB Installer (UUI) which will create bootable flashdrive for you.
- How to create the bootable flashdrive using UUI then follow this article
Once you have bootable flashdrive or DVD with you, It’s time to start installation.
- See this video to install Ubuntu as standalone operating system
Virtual machine installation
- Using oracle virtual box or VMware you can install Ubuntu and run it on windows.see this video
- See this link which is useful when you are trying to install Ubuntu along with Windows OS
For windows user who don’t want to install Ubuntu and want to learn or play around with Linux based OS then they should try Cygwin
How to open terminal
- Open the Dash by clicking the Ubuntu icon in the upper-left, type “terminal”, and select the Terminal application from the results that appear.
- Hit the keyboard shortcut Ctrl – Alt + T .
On your terminal you can see user name. In my case it is jalaj.
When you open terminal you are at system’s home location.Here ~ stands for system’s home path and your system’s home path will be /home/yourusername
So /home/jalaj is same as ~ (which is useful to understand basic commands)
To see you are currently at which location then use following command.
when you open File explorer or Folders you can see Home icon on your left side which shows you are at system’s home location
When you press Ctrl + l on title bar you can see the full path of current system location
Make directory or folder
$ mkdir /home/yoursystemusername/test
or you can do it by following this
$ mkdir ~/test
see the following picture
Change directory or jump from one location to another
$ cd /home/jalaj/test $ cd ~/test
List down directories & files
$ ls # This is for list down all directories
|Command with flags||Description|
|ls -a||list all files including hidden file starting with ‘.’|
|ls -d||list directories – with ‘ */’|
|ls -i||list file’s inode index number|
|ls -l||list with long format – show permissions|
|ls -la||list long format including hidden files|
|ls -lh||list long format with readable file size|
|ls -ls||list with long format with file size|
|ls -r||list in reverse order|
|ls -R||list recursively directory tree|
|ls -s||list file size|
|ls -S||sort by file size|
|ls -t||sort by time & date|
|ls -X||sort by extension name|
# List directory using relative path $ ls ~/test # List directory using absolute path $ ls /home/yoursystemusername/test # List root directory $ ls / # List parent directory $ ls .. # List user's home directory means /home/yoursystemusername $ ls ~ # List with long format $ ls -l # Show hidden files $ ls -a # List with long format and show hidden files $ ls -la # Sort by date/time $ ls -t # Sort by file size $ ls -S # List all sub-directories $ ls * # Recursive directory tree list $ ls -R # List only text files with wildcard $ ls *.txt # List directories only $ ls -d */ # List files and directories with full path $ ls -d $PWD/* # List files and directories with permissions in reverse order $ ls -ltr
Remove directory or files
# delete file $ rm /home/jalaj/test/test.txt # Forcefully delete write-protected file $ rm -f /home/jalaj/test/test.txt # If you are already in ~/test directory then $ rm -f ./test.txt # Current directory is referred as ./ # If remove directory $ rm /home/jalaj/test/demo # remove directory recursively $ rm -r /home/jalaj/test # remove directory recursively and forcefully $ rm -rf /home/jalaj/test # Remove all files in the working directory. # rm will prompt you for any reason before deleting them. $ rm -i *
Copy files or directory
$ cp FLAG SOURCE DESTINATION
|cp -a||archive files|
|cp -f||force copy by removing the destination file if needed|
|cp -i||interactive – ask before overwrite|
|cp -l||link files instead of copy|
|cp -L||follow symbolic links|
|cp -n||no file overwrite|
|cp -R||recursive copy (including hidden files)|
|cp -u||update – copy when source is newer than dest|
|cp -v||verbose – print informative messages|
# Copy single file main.c to destination directory bak $ cp main.c bak # Copy 2 files main.c and def.h to destination absolute path directory $ cp main.c def.h /home/jalaj/test/ # Copy all C files in current directory to subdirectory bak $ cp *.c bak # Copy directory src to absolute path directory /home/jalaj/test/ $ cp src /home/jalaj/test/ # Copy all files and directories in dev recursively to subdirectory bak $ cp -R dev bak # Force file copy to directoy $ cp -f test.txt bak # Interactive prompt before file overwrite $ cp -i test.c bak cp: overwrite 'bak/test.c'? y # Update all files in current directory # - copy only newer files to destination directory bak $ cp -u * bak
Move files or directory
$ mv FLAG SOURCE DESTINATION
|mv -f||force move by overwriting destination file without prompt|
|mv -i||interactive prompt before overwrite|
|mv -u||update – move when source is newer than destination|
|mv -v||verbose – print source and destination files|
# Move main.c def.h files to /home/jalaj/test/ directory $ mv main.c def.h /home/jalaj/test # Move all C files in current directory to subdirectory bak $ mv *.c bak # Move all files in subdirectory bak to current directory $ mv bak/* . # Rename file main.c to main.bak $ mv main.c main.bak # Rename directory bak to bak2: $ mv bak bak2 # Update - move when main.c is newer: $ mv -u main.c bak # Move main.c and prompt before overwrite bak/main.c $ mv -v main.c bak 'bak/main.c' - 'bak/main.c'
This helps.. Part – 2 is coming soon….!