Basic linux commands-Part 1

If you got to start with the Linux, A thorough knowledge in Basic linux commands is must have. without much ado lets check out the various commands and tools to begin the journey of linux. If you still need to have more clear understanding of concept before starting here, refer to what is linux 

Basic linux commands

Linux offers a wide range of commands for both privileged and non-privileged use. Privileged or Super User commands are used for system management and are meant only for privileged users. Non-privileged commands can be run with regular user rights.

These commands are essential in order to work productively and manage the system efficiently.

Understanding the command syntax

The general command syntax is :

command option argument

You can use zero or more options and arguments in a command. Some commands have default options and arguments that they use when executed, and you do not need to mention them. Other commands require At least an Argument or option. An option, also called as switch or flag, modifies the behavior of the command, and an argument works as the target on which command is executed.

To make things simpler let’s follow few examples:

$ ls (no option, no argument; the default argument is the current directory name)
$ ls –l (one option, no argument; the default argument is the current directory name)
$ ls directory_name (no option, one argument)
$ ls –l directory_name (one option, one argument)

lets discuss it in detail

Files and directory listings

The ls (list) command is one the most important and easiest of Basic Linux commands and it displays a list of files and directories on the screen. It supports several options, given below-

Option Description

a    :Lists all files along with the hidden files. If a file or directory name                       starts  with a dot, it is considered hidden.
lh   :long listing with file sizes in human readable format, i.e, Bytes, KB MB               or GB.
l      :Displays long listing with detailed file information. Includes the file                   type, permissions, link count, owner, group, size, date and time of last               modification, and name of the file
ld    :Displays long listing of the specified directory.
R     :Lists contents of the given directory and all its sub-directories                              (recursive  listing).
lt     :Lists all files sorted by date and time with the latest file first.
ltr   :Lists all files sorted by date and time with the oldest file first.

For instance the option “-a” is included in this exmple :

#ls -a
#ls -a <dir name>

The angular bracket < > is not used, it is just to show the example content inside it.

Printing Working Directory

The pwd (print working directory) command shows the user’s current location in the directory tree.

The below command when executed by the testuser from its home directory shows-

$pwd
/home/testuser

Changing the directory

The cd (change directory) command is  used to navigate the directory tree. Run the following commands as testuser.
To change directory to /usr/ bin

$ cd /usr/ bin

To go back to the home directory, issue either of the following:

$ cd
$ cd ~

To go to the home directory of testuser :

$ cd ~testuser

where ~ is “tilde” symbol.

To go to the root directory, use the forward slash character:
$ cd /

To switch between current and previous directories, use the cd command with the dash character:

$ cd

To go one directory up to the parent directory, use dot twice:

$ cd ..

Showing the Terminal name

This command displays the terminal name we are currently logged on to:

$ tty

Displaying Currently Logged-In Users

The who command jumps to the /var/ run/ utmp file and presents the list of users currently logged on to the system:

$who

Viewing User Login Name

The whoami (who am i) command displays the effective username of the person executing this command:

$ whoami

The logname (login name) command shows the name of the real user who originally logged in to the system:

$ logname

Displaying History of Successful User Login Attempts

The last command reports the history of successful user login attempts and system reboots.

To list all user login, logout, and system reboot records, use the last command without any arguments:

$last

Viewing History of Failed User Login Attempts

Among the Basic linux commands the lastb command reports the history of unsuccessful user login attempts by reading the /var/ log/ btmp file.

To list all unsuccessful login attempts, type the lastb command without any arguments.

The last and lastb Basic linux commands should be executed with the root user account privilege.

#lastb

Checking Recent User Logins

The lastlog command shows the recent user logins by accessing the /var/ log/ lastlog file. T

#lastlog

Command for system infomation

The uname command provides basic information about the system.
Without any options, this command displays the Operating System name only.

# uname
Linux

You can use the –a option to get details.

# uname –a

output:

Linux host1. example.com 3.10.0-123. el7. x86_64 #1 SMP Mon May 5 11: 16: 57 EDT 2014 x86_64 x86_64 x86_64 GNU/ Linux

The information returned by the second command is:

Linux (Kernel name)
host1. example.com (Hostname of this system)
3.10.0-123. el7. x86_64 (Kernel release)
#1 SMP Mon May 5 11: 16: 57 EDT 2014 (Date and time of this kernel built)
x86_64 (Machine hardware)

 

These are few Basic linux commands. However, there are more and I will keep you tipped up in my forthcoming posts.

 

Also check out the website for ubuntu to have an broader overview.

Linux booting process. A systematic guide on the Linux boot related concept.

As a system administrator you should have an understanding of the Linux booting process.  In this post, you will learn about BIOS, the boot loader, the Linux kernel and Runlevels.

 

Linux booting process

Lets discuss and Understand the Linux booting process one by one

The BIOS

 

The BIOS stands for Basic Input/Output System.  It’s a firmware used in the booting process and it’s the first piece of software that is executed when a computer is powered on.  The BIOS is doesn not depend onthe OS type, rather it is independent.

Its primary purpose is to test the hardware on the motherboard by executing Power On Self Test and to load a boot loader or operating system. The POST performs some basic checks of hardware components such as the CPU, memory, and storage devices.  Only if the POST succeeds, the BIOS attempt to load the boot loader.

The BIOS contains a list of bootable devices such as hard disks, DVD drive, USB devices, and others depending on what hardware is connected.

The BIOS searches the list for a bootable device in the order of boot priority.  You can change this order by getting into BIOS configuration by interrupting the boot sequence.  The key combination used to do this will be different from one hardware manufacturer to another.

Once a bootable device has been found, the BIOS runs the boot loader.  Generally the GRUB boot loader will be used, but there are other boot loader too like, LILO boot loader.  LILO is an abbreviation for LInux LOader, while GRUB stands for GRand Unified Bootloader.

The primary purpose of the boot loader is to start the operating system.  You will see a series of messages from the boot loader. These messages provides an option to interrupt the boot process and interact with the boot loader.  If there are multiple operating systems installed, you can select one.  You can also instruct the boot loader to pass different boot options to the operating system.

The Initial RAM Disk

The initial RAM disk, also known as “initrd,” is a temporary file system that’s loaded into RAM. when the linux booting process starts,  this file system contain helpers that perform hardware detection and load the necessary modules, sometimes drivers, to get the original file system mounted.  Suppose that, if the root file filesystem is located on an LVM (Logical Volume Manager) volume, the initrd image will contain the modules required to mount that logical volume as the root file system.  Once the root file system is mounted the job of initrd is done and the operating system continues loading from the actual root file system.

Kernel and Initial RAM Disk Location

The Linux kernel, the initial RAM disk, and other files needed to boot the operating system are stored in /boot.  Here is a list of contents in /boot directory for a linux system.

$ ls -1F /boot

abi-3.13.0-46-generic
config-3.13.0-46-generic
grub/
initrd.img-3.13.0-46-generic
System.map-3.13.0-46-generic
vmlinuz-3.13.0-46-generic

 

The Kernel Ring Buffer

The kernel ring buffer contains messages related to the Linux kernel.  A ring buffer is a data structure with almost constant size. If the buffer is completely full, old messages are discarded .To see the contents of the kernel ring buffer, use the command –

#dmesg

Runlevels and Targets

The last step in Linux booting process is Runlevel. Linux uses runlevels to decide which processes and services to start. The Runlevels are mentioned below :

0  :Shuts down the system
1  :Single user mode.?Used for maintenance.
2  :Multi-user mode with graphical interface. (Debian/Ubuntu)
3  :Multi-user text mode (RedHat/CentOS)
4  :Undefined
5  :Multi-user mode with graphical interface. ?(RedHat/CentOS)
6  :Reboot

Previously, runlevels were controlled by the init program.  The init configuration was stored in /etc/inittab. To change the default runlevel using init, you would edit the /etc/inittab file. However, init alternatives such as systemd and upstart are quickly taking the place of init with systemd currently being the most widely used.

Instead of runlevels, systemd has the targets.  These targets are equivalent to runlevels.  You can find the list of available targets in /lib/systemd/system. The runlevel targets are actually symbolic links to the real targets.  For example, runlevel5.target is a symlink to graphical.target.

Rebooting a System

For rebooting you can use the reboot or shutdown commands as well as the runlevel/target.

Here’s how to reboot with init using coomand :

# telinit 6

To reboot using systemd use the systemctl command :

# systemctl isolate reboot.target

To reboot using the reboot command :

# reboot
The format of the shutdown command is as follows :

shutdown [options] time [message]

The option to use reboot with shutdown format is  -r. 
You can specify the time to shutdown using the “HH:MM” format.
You can also use +N where N represents the number of minutes to wait.  Finally, you can use the “now” keyword to start immediately.  Optionally, you may specify a message that will be broadcast to all users logged into the system.

# shutdown -r now

Powering Off a System

To power off a system, you can use runlevel 0, the poweroff target, or the poweroff command. we can power-off with init by executing following command :

# telinit 0

Power off a system with systemctl :

# systemctl isolate poweroff.target

Finally, you can use the poweroff command :

# poweroff

If you need to refresh on what is Linux, refer this post. 

What is Linux?

What is Linux? Many of the devices you own probably, such as Android phones, digital storage devices, personal video recorders, cameras, wearables, and more, run on Linux. Even your car has Linux running in its controllers.

What is Linux

Linux has been around since mid 90’s. since then it reached a user base spanning wide regions. Linux is in your cars, phones, and refrigerators.Linux was (and still is) one of the most reliable, secure, and worry-free operating systems available, before it became the platform to run desktops, servers, and embedded systems across the globe.

Worry not-here is all the information you need to get up to speed on the Linux platform.

Linux is the best-known and most-used open source operating system. As an operating system, Linux is software that sits underneath all of the other software on a computer, receiving requests from those programs and relaying these requests to the computer’s hardware

The term “Linux” is generally used to refer to the Linux kernel, but also the set of programs, tools, and services that are included together with the Linux kernel to provide all of the components of an operating system. Some people, specially members of the Free Software Foundation, refer to this collection as GNU/Linux, for the reson many of the tools included are GNU components. But there are operating systems which does not include GNU tools and components as a part of their operating system. Android, for example, uses a Linux kernel but uses its own tool. And so does Redhat.

How is Linux different from other Operating Systems?

Like other operating systems, may have graphical interface, and types of software you are used to on other operating systems, such as office tool, have Linux variants. In many cases, you wil find Linux version of the same program you use on other systems. If you use a computer or other electronic device, you can use Linux.

But Linux is also different from other OS platforms in various ways. First of all, Linux is open source software. The source code which is used to create Linux is free and available to the public to edit, view, and—for users with the advance skills—to contribute to.

Though the core components of the Linux operating system are generally common, there are distributions of Linux, which have different software options. It makes Linux is highly customizable, because not just applications, such as text editors and web browsers, can be swapped out. Linux users also can choose core components, such as CLI or GUI, and other user-interface components.

Who are the Linux users?

Chances are you’re probably already using Linux, whether you know it or not. Between one- and two-thirds of the webpages on the Internet are generated by servers running above Linux.

The Companies and individuals prefer Linux for their servers because for its security features, and one can get excellent support from a large community of users. Also companies like Canonical, SUSE, and Red Hat, offer commercial support.

How was Linux created?

Linux was created in 1991 by Linus Torvalds, a student at the University of Helsinki. Torvalds built linux as a free and open source alternative of minix, a Unix based OS that was popularly used in academic setups. He originally wanted to name it “Freax,” but the server administrator Torvalds used to distribute the original code named his directory “Linux” after a combination of Torvalds’ first name and the word Unix, and the name remained.

How can start using Linux?

Chances are you’re using Linux already and not aware of it, but if you want to install Linux on your home computer for a try out, the easiest way is to pick a popular linux distribution that is designed for your hardware type (for example, laptop or tablet device) and give it a shot. Although there are several distributions on the internet, most of the older, well-known distributions are good choices for beginners because of its large user communities that can help troubleshoot if you get stuck somewhere. Popular distributions include Debian, Fedora, Mint, and Ubuntu, but there are many others.

Where can I start learning about Linux?

Four Linux distros for kids

Want a fulfilling IT career? Learn Linux

Building a Linux lab and its great potential in education

slow running computer? fix it by following these simple steps!

Are you wasting time waiting for an application to respond? Probably you might grab some coffee while it loads, or you can try figuring out the reason for slow running computer.

slow running computer

A lot of things in life goes slow, we can live with it. But a slow running computer isn’t so much of a fun.

The steps mentioned below will give an outlook on what can be done when a snail speed computer gives you a hard time.

1. Reboot

Rebooting the computer which is running since a long time might help. Sometimes the PC can be a mystery box and a simple reboot can fix the issue.

2. Temp files

The computer creates the temporary files while running programs. Deleting temporary files can free up space on hard disk and speed it up.

There are several utilities for it. Disk Cleanup is one such tool to delete temp files and other files no longer needed.

Alternatively, we can use the command %temp% from the “Run” option. once inside delete all the temp files.

3. Background programs

Disable or remove the “startup programs” which automatically starts when system boots.

To check out the program running in background and how much of cpu they are using, open “Task manager”.

Any Antivirus or security utility scanning the system in the background can slow down the computer.

4. Less Hard drive space

Make sure there is atleast 200-500 MB of free hard drive space.

“Swap files” can improve performance

5. Damaged or fragmented hard drive

Use “chkdsk” command or other utility to check hard drive physical corruption level.

Run “Defrag” to arrange data in best order on disk.

Get information about drive errors by reading “SMART” info using tools.

6. Check for malware

Malware and spywares can be the cause of multiple problems in computer. A regular malware scan on slow running computer saves the computer system from unexpected problems. Beware of the suspicious and fishy links when you browse through the internet. This link will provide you an insight on different types of malware.

7. Virus scan

viruses can make your computer really slow. Install a good “antivirus” to keep the viruses in check. You can use some free online antiviruses too if you don’t have one installed for active protection.

8. Windows Update

Keep your windows updated by installing updates regularly.

Update the browser plugins.

9. RAM upgrades

To run programs smoothly we need sufficient RAM. Increase the size of RAM on older computers.

To know how much RAM is installed, check “system properties” or use the command “msinfo32”.

Also run the program “windows memory diagnostic” to check the damage to the RAM at any point.

10. Overheating Processor

Use proper cooling solution(fan or liquid cooling) to ensure the processor doesn’t heats up soon during high activity.

Make sure the “Heat sink paste” or “Thermal Compound” has not dried up completely on the processor surface.

11. Reinstall everything

After trying the above solutions, if you still have slow running computer, Format disk and reinstall OS. Well, don’t forget to backup important data before formatting your disk.

12. Hardware Problem

Finally the failing hardware can be the reason of computer running slow. A bad Hard drive, RAM, CPU, or Motherboard can be the reason for slow or freezing computer system.

Further, you can run tools like, “ultimate DLCD” or ” Hiren’s Boot disk” to diagnose the problem.

Mostly the steps mentioned will provide a solution. If not, then definitely you got to contact helpdesk.

Mobile number portability might not be an option soon for Indian Mobile phone customers

The mobile number portability might raise concerns for the mobile phone users in the coming year.Mobile number portability

NEW DELHI: The mobile phone users planning to change service provider while keeping the old number will have difficulties after March next year.

Mobile number portability (MNP), as it’s called, is functioning properly right now but the two companies which is responsible for the service in India — MNP Interconnection Telecom Solutions and Syniverse Technologies — have written to the Department of Telecommunications (DoT) that the almost-80% reduction in porting charges since January this year has resulted into daily losses and they have to close services once their licence terms come to an end in March 2019, said people with the concern of the matter.

If this happens, customers who want to change their service provider due to billing issues, poor call qualities or irrelevant tariffs will have no option to do so — at least in the near term.

 

A DoT official said the policy for mobile number portability might change if the issue isn’t settled in time.

Monthly MNP requests have increased tremendously in near past. With the entry of Reliance Jio Infocomm and exits by Reliance Communications, Tata Teleservices, Aircel and Telenor India, the older operators Bharti Airtel, Vodafone India and Idea Cellular are dropping tariff rates to retain or attract customers.

MNP Interconnection(which handles east and south India), has said it will halt its operation and surrender the lincense, while Syniverse Technologies, which handles north and western India, has mentioned its alarming financial problems to DOT due to the Telecom Regulatory Authority of India (Trai) order to reduce charges down to Rs 4 per transaction from a previous charge of Rs 19.

Both the companies has handled more than 370 million porting requests until March this year. They have also moved court against the regulator, on the grounds of arbitrary and non-transparent transactions. The case will be heard next on July 4.
“We have written to DoT that our company will not be able to provide MNP services mainly because the tariff has been revised to as low as Rs 4, which has made the business unsustainable as we’re facing losses on a daily basis and can’t even pay salaries,” said a senior executive at MNP Interconnection Telecom Solutions to ET on the condition of anonymity.