This post is intended for Linux beginners and based on Ubuntu 16.04. Linux host system can be utilized for Linux host specific applications, Browsing source code of open source projects, Developing Linux Applications, Device Drivers, Kernel Modules and also for developing bare-board embedded projects using GNU tools. I have already discussed possible Ubuntu installation options in my earlier post.
Ubuntu 16.04 Walkthrough: Lets get familiar with the operating system first. You may find most frequently used applications/utilities similar to Search on PC, Files Explorer, Web Browser, Word, Worksheet, Powerpoint, System, Cmd Prompt in Windows, Only the names are related to application provider. Obviously there is a software center to install new application. If you use this Linux platform even under Windows (via VirtualBox) , you will start loving Ubuntu. You may watch this at Embedkari
System Administration : root user works as system administrator. It can create new users and it can also provide them root level access for selective commands or all using sudo(Super User DO)
We can refer to simple kernel architecture here
Linux shell : Shell is a command interpreter between external world(User/Applications) and Operating system. Every Operating system used to have both GUI and CLI(Command Line Interface) shells.
Which shell I am using ? GUI shell can be found with env or echo $XDG_CURRENT_DESKTOP. Ubuntu16.04 has Unity shell. CLI has bash shell by default. CLI shell commands can be arranged in a file called shell script for complex operations similar to batch files in Windows.
CLI shell can be found with echo $0 or echo $SHELL
What other Shells are available on my Ubuntu distribution ?
cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/screen
You may change shell using sudo chsh
What are the shell built-in (Internal) commands
We can open terminal window by right click anywhere and select open terminal. You may use help command to list the built-in commands in the shell. For ex : If you found pwd , You may use help command again to get detail about this.
sanjay@sanjay-VirtualBox:~$ help pwd
pwd: pwd [-LP]
Print the name of the current working directory.
sanjay@sanjay-VirtualBox:~$ pwd
/home/sanjay
How to know if a particular command is built-in(Internal) or external ? Command type can be found by type command -)
sanjay@sanjay-VirtualBox:~$ type pwd
pwd is a shell builtin
What happens when a command (e,g List Segments aka ls) is not builtin ?
Shell will look into PATH environment variable Try echo %PATH and ls command Then change PATH with export PATH=/user . Finally observe result of echo $PATH and ls again
ls display all files, even the hidden ones, by giving it the -a (all) option:
For example, the -l option to ls gives more information, including the size of files and the date they were last modified. You may try ls -a or ls -a or a combination ls -lart . All possible options can be found with ls –help
Where can I find external commands ?
Linux Filesystem:
You may go to root(Admin level system directory) directory by cd / and come back to user home by cd ~ or cd /home/username
/bin Essential command binaries such as ls, cat , cp etc
/sbin Essential system binaries such as fsck, init, route etc
/usr/bin Non-essential binaries such as cmp,diff,find etc
/usr/sbin Non-essential system binaries such as ethtool,mkfs
/lib Libraries necessary for binaries in /bin and /sbin
/usr/lib Libraries required for binaries in /usr/bin and /usr/sbin
/usr Non-essential user applications
/etc System configuration files
/var This is a folder where services can store files such as log files, emails etc. Size of these files can vary during normal operation.
/var/lock Files keeping track of resources in use
/var/log Log files
/home – User’s home directories. Normal users can only write to their own home directory.
/dev The /dev tree contains device nodes, which gives user space access to the device drivers in the running kernel. This also contains virtual devices such as /dev/null , /dev/random and /dev/tty .
/proc This was originally for providing process information in UNIX. Linux extended it for kernel information as well.
/sys is a better organized method than /proc.
One can use history command to list commands used in the particular terminal window.
How can I get more information about a particular command ? Using help or man commands provided corresponding manual is available.
Internal or shell commands example : help echo
External command example : df –help or man df
What is the sequence Shell follow for executing a command?
Whenever user type a command , Shell looks into aliases,shell functions,built-in commands,hash table,$PATH respectively.Hash table keeps a copy of command’s path executed in past to avoid $PATH based search every time .
sanjay@sanjay-VirtualBox:~$ type dir
dir is hashed (/bin/dir)
sanjay@sanjay-VirtualBox:~$ hash -r
sanjay@sanjay-VirtualBox:~$ type dir
dir is /bin/dir
sanjay@sanjay-VirtualBox:~$
I am trying to improve usability of my blog site. Did you find this blog post helpful ? If so, Could you help to grow my readership by sharing this blog post ? Please subscribe to youtube channel Embedkari for further detail.
.