Search This Blog

Thursday, 5 January 2017

Basic Linux Operation: Week 5-6

BASIC LINUX OPERATION

Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. Its functionality list is quite similar to that of UNIX.


Components of Linux System

Linux Operating System has primarily three components
  • Kernel − Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs.
  • System Library − System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating system and do not requires kernel module's code access rights.
  • System Utility − System Utility programs are responsible to do specialized, individual level tasks.
Linux Operating System

Kernel Mode vs User Mode

Kernel component code executes in a special privileged mode called kernel mode with full access to all resources of the computer. This code represents a single process, executes in single address space and do not require any context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to processes, provides protected access to hardware to processes.
Support code which is not required to run in kernel mode is in System Library. User programs and other system programs works in User Mode which has no access to system hardware and kernel code. User programs/ utilities use System libraries to access Kernel functions to get system's low level tasks.

Basic Features

Following are some of the important features of Linux Operating System.
  • Portable − Portability means software can works on different types of hardware in same way. Linux kernel and application programs supports their installation on any kind of hardware platform.
  • Open Source − Linux source code is freely available and it is community based development project. Multiple teams work in collaboration to enhance the capability of Linux operating system and it is continuously evolving.
  • Multi-User − Linux is a multiuser system means multiple users can access system resources like memory/ ram/ application programs at same time.
  • Multiprogramming − Linux is a multiprogramming system means multiple applications can run at same time.
  • Hierarchical File System − Linux provides a standard file structure in which system files/ user files are arranged.
  • Shell − Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs. etc.
  • Security − Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.

Architecture

The following illustration shows the architecture of a Linux system −
Linux Operating System Architecture The architecture of a Linux System consists of the following layers −
  • Hardware layer − Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).
  • Kernel − It is the core component of Operating System, interacts directly with hardware, provides low level services to upper layer components.
  • Shell − An interface to kernel, hiding complexity of kernel's functions from users. The shell takes commands from the user and executes kernel's functions.
  • Utilities − Utility programs that provide the user most of the functionalities of an operating systems.
Basic linux Operations Commands


This document provides a basic list of commands and how they can be used to perform basic operations.

Operation Commands List

any_command /--help |more

Display a brief help on a command (works with most commands). "--help" works similar to DOS "/h" switch. The "more" pipe is needed if the output is longer than one screen.
[thesmartguy@wifitest ~]$ apropos --help
usage: apropos keyword ...

man topic

Display the contents of the system manual pages (help) on the topic. Try man man first. Press "q" to quit the viewer. The command info topic works similar and may contain more up-to-date information. Manual pages can be hard to read. Try any_command --help for short, easy to digest help on a command. If more info needed, have a look to the directory /usr/doc. To display manual page from a specific section, I may use something like in this example: man 3 exit (this displays an info on the command exit from section 3 of the manual pages).
[thesmartguy@wifitest ~]$ man apropos

apropos topic

Give me the list of the commands that have something to to do with my topic.
[thesmartguy@wifitest ~]$  apropos lsmod
lsmod                (8)  - program to show the status of modules in the Linux Kernel

ls

List the content of the current directory. Under Linux, the command "dir" is an alias to ls. Many users have "ls" to be an alias to "ls --color".
[thesmartguy@wifitest ~]$ ls
Desktop    power Fig 1.png  power Fig 5.png  power Fig 9.png  toss
Documents  power Fig 2.png  power Fig 6.png  pt Fig 5.png     user
Downloads  power Fig 3.png  power Fig 7.png  rc Fig 1.png     workplace-tmp
lotus      power Fig 4.png  power Fig 8.png  rc Fig 2.png

ls -al |more

List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the "more" command, so that the display pauses after each screenful

Example shows ls pointed at a specific directory normal use is from within a directory.
[thesmartguy@wifitest ~]$ ls -al user
total 12
drwxrwxr-x  3 thesmartguy thesmartguy 4096 Nov 10 18:44 .
drwx------ 41 thesmartguy thesmartguy 4096 Nov 19 09:33 ..
drwxrwxr-x  2 thesmartguy thesmartguy 4096 Nov 10 18:44 .expeditor
Displays hidden files marked with a dot.filename and file permission

cd directory

Change directory. Using "cd" without the directory name will take you to your home directory. "cd -" will take you to your previous directory and is a convenient way to toggle between two directories. "cd .." will take you one directory up.
[thesmartguy@wifitest ~]$ cd /etc
[hesmartguy@wifitest etc]$
Changed directory frome  wifitest  to etc.

cp source destination

Copy files. E.g., cp /home/stan/existing_file_name . will copy a file to my current working directory. Use the "-r" option (for recursive) to copy the contents of whole directories, e.g. , cp -r my_existing/dir/ ~ will copy a subdirectory under my current working directory to my home directory.
[thesmartguy@wifitest ~]$ cp toss /tmp
copies file named toss to tmp directory no confirmation will be received cd to tmp to confirm.

mcopy source destination

Copy a file from/to a DOS filesystem (no mounting necessary). E.g., mcopy a:\autoexec.bat ~/junk . See man mtools for related commands: mdir, mcd, mren, mmove, mdel, mmd, mrd, mformat ....

mv source destination

Move or rename files. The same command is used for moving and renaming files and directories.
[thesmartguy@wifitest ~]$ mv toss jimmit
This will rename toss = jimmit again no confirmation do a ls to check. by pathing command you can rename and send to another directory i.e. mv toss /tmp/jimmit

ln source destination

Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it. Any changes the file are automatically visible throughout. When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: the files have to be on the same filesystem, hard links to directories or special files are impossible.

ln -s source destination

Create a symbolic (soft) link called "destination" to the file called "source". The symbolic link just specifies a path where to look for the file. In contradistinction to hard links, the source and destination don't not have to tbe on the same filesystem. In comparison to hard links, the drawback of symbolic links are: if the original file is removed, the link is "broken", symbolic links can also create circular references (like circular references in spreadsheets or databases, e.g., "a" points to "b" and "b" points back to "a").

rm files

Remove (delete) files. You must own the file in order to be able to remove it. On many systems, you will be asked or confirmation of deleation, if you don't want this, use the "-f" (=force) option, e.g., rm -f * will remove all files in my current working directory, no questions asked.
[thesmartguy@wifitest ~]$ rm -f jimmit
Removes jimmit file again no confermation.

rm -r files

(recursive remove) Remove files, directories, and their subdirectories. Careful with this command as root--you can easily remove all files on the system with such a command executed on the top of your directory tree, and there is no undelete in Linux (yet).
[thesmartguy@wifitest ~]$ rm -rf /user/*
(Deletes files in user directory)

mkdir directory

Make a new directory.
[thesmartguy@wifitest ~]$ mkdir test
Makes directory test no confermation do ls command to check.

rmdir directory

Remove an empty directory.
[thesmartguy@wifitest ~]$ rmdir test
(No confermation)

cat filename | more

View the content of a text file called "filename", one page a time. The "|" is the "pipe" symbol (on many American keyboards it shares the key with "\") The pipe makes the output stop after each screenful. For long files, it is sometimes convenient to use the commands head and tail that display just the beginning and the end of the file. If you happened to use "cat" a binary file and your terminal displays funny characters afterwards, you can restore it with the command "reset".
[thesmartguy@wifitest ~]$ cat test
hello testing cat

less filename

Scroll through a content of a text file. Press q when done. "Less" is roughly equivalent to "more" , the command you know from DOS, although very often "less" is more convenient than "more".

find / -name "filename"

Find the file called "filename" on your filesystem starting the search from the root directory "/". The "filename" may contain wildcards (*,?).

locate filename

Find the file name of which contains the string "filename". Easier and faster than the previous command but depends on a database.
Use updatedb this will rebuild the database a cron job can be set up to update database daily or weekley

./program_name

Run an executable in the current directory, which is not on your PATH. You may need to use chown a+x ./program_name first to make the application executable.

touch filename

Change the date/time stamp of the file filename to the current time. Create an empty file if the file does not exist.

Install Ubuntu 16.04 LTS

  1. Using a DVD?
    It’s easy to install Ubuntu from a DVD. Here’s what you need to do:
    Put the Ubuntu DVD into the DVD-drive
    Restart your computer. You should see a welcome screen prompting you to choose your language and giving you the option to install Ubuntu or try it from the DVD.
    If you don’t get this menu, read the booting from the DVD guide for more information.

    Using a USB drive?

    Most newer computers can boot from USB. You should see a welcome screen prompting you to choose your language and giving you the option to install Ubuntu or try it from the USB.
    If your computer doesn’t automatically do so, you might need to press the F12 key to bring up the boot menu, but be careful not to hold it down - that can cause an error message.

  2. Prepare to install Ubuntu
    • We recommend you plug your computer into a power source
    • You should also make sure you have enough space on your computer to install Ubuntu
    • We advise you to select Download updates while installing and Install this third-party software now
    • You should also stay connected to the internet so you can get the latest updates while you install Ubuntu
    • If you are not connected to the internet, you will be asked to select a wireless network, if available. We advise you to connect during the installation so we can ensure your machine is up to date

  3.  Allocate drive space
    Use the checkboxes to choose whether you’d like to Install Ubuntu alongside another operating system, delete your existing operating system and replace it with Ubuntu, or — if you’re an advanced user — choose the ’Something else’ option
  4. Begin the installation
    Depending on your previous selections, you can now verify that you have chosen the way in which you would like to install Ubuntu. The installation process will begin when you click the Install Now button.
    Ubuntu needs about 4.5 GB to install, so add a few extra GB to allow for your files.

  5. Select your location
    If you are connected to the internet, this should be done automatically. Check your location is correct and click ’Forward’ to proceed. If you’re unsure of your time zone, type the name of the town you’re in or click on the map and we’ll help you find it.

    TIP: If you’re having problems connecting to the Internet, use the menu in the top-right-hand corner to select a network.

  6. Select your preferred keyboard layout
    Click on the language option you need. If you’re not sure, click the ’Detect Keyboard Layout’ button for help.
  7. Enter your login and password details

  8. Learn more about Ubuntu while the system installs…
    …or make a cup of tea!
  9. That’s it.
    All that’s left is to restart your computer and start enjoying Ubuntu!

No comments:

Post a Comment