Why some file names are preceded by a dot in Linux?

In general, filenames that are preceded by a dot are hidden files. These files can be configuration files that hold important data or setup info. Setting these files as hidden makes it less likely to be accidentally deleted.

What are the kinds of permissions under Linux?

There are 3 kinds of permissions under Linux:
- Read: users may read the files or list the directory
- Write: users may write to the file of new files to the directory
- Execute: users may run the file or lookup a specific file within a directory

How do you terminate an ongoing process?

Every process in the system is identified by a unique process id or pid. Use the kill command followed by the pid in order to terminate that process. To terminate all process at once, use kill 0.

How to get information about memory consumption in Linux?

Run command "cat /proc/meminfo", this will display detail information about memory utilization. The information comes in the form of both high-level and low-level statistics.

What are symbolic links in Linux?

Symbolic links act similarly to shortcuts in Windows. Such links point to programs, files or directories. It also allows you instant access to it without having to go directly to the entire pathname.

What are hard links in Linux?

Hard links point directly to the physical file on disk, and not on the path name. This means that if you rename or move the original file, the link will not break, since the link is for the file itself, not the path where the file is located.

What is the maximum length for a filename under Linux?

Any filename can have a maximum of 255 characters. This limit does not include the path name, so therefore the entire pathname and filename could well exceed 255 characters.

What is BASH?
BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. It has since been adapted as the default shell for most systems running Linux.

What is Linux Kernel?

The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction.

What is the basic difference between BASH and DOS?

The key differences between the BASH and DOS console lies in 3 areas:
  • BASH commands are case sensitive while DOS commands are not;
  • under BASH, / character is a directory separator and \ acts as an escape character. Under DOS, / serves as a command argument delimiter and \ is the directory separator
  • DOS follows a convention in naming files, which is 8 character file name followed by a dot and 3 character for the extension. BASH follows no such convention.

What is fork bomb in Linux?

In computing, a fork bomb is a denial-of-service attack whereby a process continually replicates itself to deplete available system resources.
The concept is to create the processes continually replicate themselves, potentially causing a denial of service. A basic implementation of a fork bomb takes the following form:

set running to true
while running is true
    create copy of running process
end

Most elegant fork bomb was created by Jaromil in 2002 by pasting the following 13 characters in shell
 :(){ :|:& };:

Why everything on Linux is File

One of the defining features of Linux is that everything is a file. Things on Linux appear as your file system, but they aren’t actually files. They’re 
special files that represent hardware devices, system information, and other things — including a random number generator. Files can be divided into three categories; ordinary or plain files, directories, and special or device files.

Directories in Linux are properly known as directory files. They are a special type of file that holds a list of the other files they contain.

Ordinary or plain files in Linux are not all text files. They may also contain ASCII text, binary data, and program input or output. Executable binaries (programs) are also files, as are commands. When a user enters a command, the associated file is retrieved and executed. This is an important feature and contributes to the flexibility of Linux.

These special files may be located in pseudo or virtual file systems such as /dev, which contains special files that represent devices, and /proc, which 
contains special files that represent system and process information.

/proc ::  Example, let’s say you want to find information about your CPU. The /proc directory contains a special file – /proc/cpuinfo – that contains this 
information. You don’t need a special command that tells you your CPU info – you can just read the contents of this file using any standard command 
that works with plain-text files. For example, you could use the command cat /proc/cpuinfo to print this file’s contents to the terminal – printing your 
CPU information to the terminal. You could even open /proc/cpuinfo in a text editor to view its contents.
Remember, /proc/cpuinfo isn’t actually a text file containing this information – the Linux kernel and the proc file system are exposing this information 
to us as a file. This allows us to use familiar tools to view and work with the information.

The /proc directory also contains other similar files, for example:
/proc/uptime :: Exposes the uptime of your Linux kernel – in other words, how long your system has been on without shutting down.
/proc/version :: Exposes the version of your Linux kernel.
/dev :: files that represent devices. For example, /dev/cdrom is your CD-ROM drive. /dev/sda represents your first hard drive, while /dev/sda1 represents the first partition on your first hard drive.

Explain Linux directory structure.

The Filesystem Hierarchy Standard defines the structure of file systems on Linux operating systems. 
/ – The Root Directory :: Everything on your Linux system is located under the / directory, known as the root directory.

/bin – Essential User Binaries :: The /bin directory contains the essential user binaries (programs) that must be present when the system is mounted 
in single-user mode.

/boot – Static Boot Files :: it contains the files needed to boot the system – for example, the GRUB boot loader’s files and your Linux kernels are 
stored here.

/dev – Device Files :: Linux exposes devices as files, and the /dev directory contains a number of special files that represent devices. 

/etc – Configuration Files :: The /etc directory contains configuration files, which can generally be edited by hand in a text editor. Note that the /etc/ 
directory contains system-wide configuration files – user-specific configuration files are located in each user’s home directory

/home – Home Folders :: it contains a home folder for each user.

/lib – Essential Shared Libraries :: it contains libraries needed by the essential binaries in the /bin and /sbin folder. Libraries needed by the binaries 
in the /usr/bin folder are located in /usr/lib.

/lost+found – Recovered Files :: Each Linux file system has a lost+found directory. If the file system crashes, a file system check will be performed at 
next boot. Any corrupted files found will be placed in the lost+found directory, so you can attempt to recover as much data as possible.

/media – Removable Media :: it contains subdirectories where removable media devices inserted into the computer are mounted. For example, when 
you insert a CD into your Linux system, a directory will automatically be created inside the /media directory.

/mnt – Temporary Mount Points :: it is where system administrators mounted temporary file systems while using them.

/opt – Optional Packages :: directory contains subdirectories for optional software packages. 

/proc – Kernel & Process Files :: it is similar to the /dev directory because it doesn’t contain standard files. It contains special files that represent 
system and process information.

/root – Root Home Directory :: it is the home directory of the root user. Instead of being located at /home/root, it’s located at /root. This is distinct 
from /, which is the system root directory.

/run – Application State Files :: it is fairly new, and gives applications a standard place to store transient files they require like sockets and process 
IDs. These files can’t be stored in /tmp because files in /tmp may be deleted.

/sbin – System Administration Binaries :: it contains essential binaries that are generally intended to be run by the root user for system 
administration.

/srv – Service Data :: it contains data for services provided by the system.

/tmp – Temporary Files :: Applications store temporary files in the /tmp directory. These files are generally deleted whenever your system is restarted 
and may be deleted at any time by utilities such as tmpwatch.

/usr – User Binaries & Read-Only Data :: it contains applications and files used by users, as opposed to applications and files used by the system. 

/var – Variable Data Files :: it is the writable counterpart to the /usr directory, which must be read-only in normal operation. Log files and everything 
else that would normally be written to /usr during normal operation are written to the /var directory. For example, you’ll find log files in /var/log.

How to map a Windows drive in Linux

To map a drive in Linux, use below command
mount –t FileSystem –o username=username,password=password //UNCpath /DesiredMapName
You can use FileSystem as cifs or smbfs
Example
mount –t cifs –o username=administrator,password=Pass123 //server/nscap /mount1 

Check the status of firewall in linux.

To check the status of firewall, run command service iptables status. It will display the message with the firewall status eg. Firewall is stopped. 

Start/Stop firewall in linux.

To start, stop or restart the firewall in linux, run following commands:
start: service iptables start
stop: service iptables stop
restart: service iptables restart 

Sync your hardware clock with the system time in Linux.

Use  hwclock --systohc command to sync your hardware clock with the system time in Linux. Use hwclock --show command to read hardware clock and print the result. 

Disable FTP in Linux.

Edit inetd.conf file in /etc folder and comment ftp. This will not allow connection between a FTP client to another server. 

Modify a user account in Linux.

To modify a user account, use command usermod. 
syntax: usermod [-c comment] [-d home_dir [ -m]] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,…]] [-l login_name] [-p passwd] [-s shell] [-u uid [ -o]] [-L|-U] login 

Know when your Linux system got rebooted last time.

Use command last reboot to know when your linux system got rebooted last time.

List down mounted file systems in Linux.

Use command to list mounted file systems in Linux :: mount | column -t

Display CPU info of Linux system.

Command grep model name /proc/cpuinfo will display CPU information present in the system. 

Display Total RAM seen by Linux system.

Following command grep MemTotal /proc/meminfo will display total RAM seen by the system. 

List all the partitions registered on the system in Linux.

Type command cat/proc/partitions on the prompt to list all partitions registered on your Linux system. 

Want to check who is on the system in Linux.

Type finger username command followed by name of user account to get information about the user or type finger and press enter to see who is on the system and what are they doing. 

Converting and copying a file in linux.

By using following command user can convert and copy files in linux dd if=report of=document conv=ebcdic, ucase . Above command converts the input file (if) report from ascii to ebcdic and while converting map alphabetic characters in uppercase and copy them to output file (of) called document. Other options available with dd command are:
i) count = n copy only n input records
ii) conv = ascii convert ebcdic to ascii
iii) conv = lcase convert alphabets to lower case 
iv) conv = noerror continue processing if error encountered 
v) skip = n skip n input records before starting copy
vi) bs = bytes. 

Overview of rpm commands in Linux.

Commands for installing, uninstalling, upgrading, querying, listing and checking RPM packages on Linux system:
i) Install a RPM package with following command: rpm -I packagefile.rpm 
ii) Uninstall RPM package with following command: rpm -e packagefile.rpm 
iii) Upgrade RPM package with following command: rpm -Uvh packagefile.rpm 
iv) Querying all installed package: rpm -qa 
v) Querying a RPM package with following command: rpm -q packagefilename 
vi) To display package information use following command: rpm -qi packagefilename 
vii) To list files in installed package use following command: rpm -ql packagefilename 
viii) Determine which installed package a particular file belongs to with following command: rpm -qf /usr/bin/filename 
ix) List files in uninstalled RPM file with following command: rpm -qpl packagefile.rpm 
x) Check RPM signature package to ensure its integrity and origin with following command: rpm --checksig packagefilename 

Display contents of a file in Linux, one screen at a time.

Type command more filename to display file on terminal one screenfull at a time. Command less can also be used for this purpose. Less is a program similar to more but allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi. 

Cancel or kill a process in Linux.

kill pid command is used to kill a process. Pid is the process id. 
To know the process id run ps command on console, all running processes will be listed. 

How to display status of network or ports in Linux.

Using netstat command one can know status of various ports. Options available are:
eg. Netstat [-a] [-n] [-v] 
-a - Displays State of all sockets and routing table entries.
-n - Displays network addresses as number otherwise are displayed as symbols.
-v - Verbose to display added information for sockets and routing table 
-m - Displays STREAMS statistics
-p -Display the address resolution (ARP) tables.
-I -Display state of the interfaces that are used for TCP/IP traffic
-r - Display routing tables
-d -Display state of all interfaces that are under Dynamic Host Configuration Protocol (DHCP) control
-D - Show the status of DHCP configured interfaces
-P protocol - Limit display of statistics or state of all sockets to those applicable to protocol.
-l interface - Display the state of a particular interface. Interface can be any valid interface such as ie0 or le0. 

Want to know route of a packet they follow to reach destination.

Type traceroute machinename_oripcommand on console to know route of a packet. One can also use tracepath machinename_orip command which is similar to traceroute but this command does not take complicated options. This command is very useful when there are network or router problems. 

How to know hostname of the computer in linux.

Type hostname command on console to know host name of the computer they are logged into. 

Execute a program periodically and showing its output full screen.

To execute a program peridically and see its output, use command watch. Syntax
watch [options] command command_options. Few options:
-n: Specify an interval to run command
-d: Highlight the differences between successive updates. 

Get total amount of disk space used by the specified files and for each subdirectory.

Disk Usage report the amount of disk space used by the specified files and for each subdirectory. Syntax du [options]… [file] …. A few most frequently use arguments
du -a (all files)
du -k (in KB)
du -h (Human readable format)
du -s (Displays total, not details) 

Display a calendar in Linux.

To display a calendar, run command cal. Syntax Cal [month] [year]. Eg:
cal 10 2008 - would display calendar for October 2008. 

Display kernel messages in Linux.

The dmesg command is used to write the kernel messages in Linux. It displays messages from /var/log relative to the most recent boot. Syntax dmesg

Get information about memory in Linux.

Run command free, it gives used and free memory usage on screen along with useful information. 

Check the history of commands executed.

Run command history to display last 500 commands executed previously. To display last n comannds run history n eg. History 10, to check last 10 commands.

How long linux system is been running and who all users are logged in ?
Type uptime command on console, output is one line containing following information:
how long system has been running,
how many users are currently logged in and
system load averages for past 1,5 and 15 minutes. 

How to display top CPU processes in linux.

Type top command on console to list most CPU-intensive tasks on the system 

How to know kernel version in linux.

Type uname -a command on console to know kernel version, linux distribution, cpu information and more . If user wants only kernel version as output then switch is replaced by uname -r 

How to search for a file in linux.

Type find / -name filename -print command on console to search location of a file. This command will search files in root directory of file system. If user wants to search files in etc directory then / will be replaced by /etc in command.User has to login as root to search 

Display currently logged in users in linux

Type who command on console to display users currently logged in to your linux machine. who am I command displays current user id and name logged in. 

Remove folders and its contents recursively

Use rm -rf foldername command to remove folder and its contents recursively.rm command will remove or delete everything in the current directory without any warning so be sure before firing this command. 

Displaying last part of file in linux

tail is the command used to display last few lines or to monitor a file. Format: tail -f filename -f is the option with the help of which you will have a file continuously appending new lines which is useful while debugging log files. If user wants only 10 lines to be displayed then following command must be used tail -n 10 filename. Similarly any desired number of lines can be displayed. 

Changing owner of a file in linux

Command chown is been used to change owner of a file. Format: chown [-R] newusername file -R changes permission on files that are in subdirectories of directory that you are currently in. eg. Chown user1 filename.txt - This command gives permissions as owner to user user1. 

Change access permissions of a particular file in linux

Command chmod is been used to change access permissions.Format: chmod [options] [Mode] file, one can give options as: -f,--silent,--quiet to supress error messages,-v, --verbose for output a diagnostic for every file processed, -c, --changes like verbose but report only when a change is made and to assign permissions use following numeric modes: the octal (0-7) value is calculated by adding values for each digit read+write+execute = 4+2+1 = 7, read+execute = 4+1 = 5 and read+write = 4+2 = 6 eg. Read permission can be set as chmod 444 file, read, write and execute can be set as chmod 777 file

Create empty file in Linux

Command touch is used to create empty file.eg.touch filename creates empty file called filename. 

Copy files in linux

Command cp is used to copy files eg.cp oldfile newfile will copy existing oldfile to newfile. 

Concatenating files in Linux

For cancatenation of files in linux,command cat is used which is multipurpose, let us discuss one by one:
i) Displaying contents: cat filename displays contents of a file
ii) Creating new file: cat >filename will create new file filename,click Ctrl-D to exit from entry mode
iii)Combining text files: cat file1 file2 >file3 will combine file1 and file2 to file3
iv) Delete contents of file: cat /dev/null >filename will delete contents from filename. 

Renaming files in Linux

Command mv is used to rename a file eg.mv oldfile newfile will rename oldfile to newfile. 

Creating and removing directories in Linux

To create new directory use mkdir. To remove use rmdir or rm -r eg.mkdir test creates test directory and rmdir test or rm -r test removes test directory. 

Displaying current working directory in linux

Type pwd on console to display current working directory 

Copying files over ssh using scp command line tool

scp is simplest command line tool to copy files over ssh.Format for scp:-scp filename user@destinationip:destination file eg.scp first.txt admin@111.111.11.11:/tmp 

Modifying date in linux system

If you want to set date in linux run date MMDDhhmm to set current system date/time. Eg : date 07280517
Note: You need to login as root user. 

Editing files in linux in normal mode

Use vi filename to open a file in normal mode. To add text click I (insert mode) which will allow user to modify files. To exit insert mode click Esc. To exit from vi press:q and click enter to exit from editing mode. 

Want to know what is date in Linux system

Type date command on console, system will display date used by the system.

Want to know which Red Hat Linux version is been installed

Run command on console: cat/etc/redhat-release 

Lost password, but you can still login.

If you have lost you root password, you can still login. When the LILO boot prompt, type linux single where you usually type linux. Now you can use passwd utility for new password. 

How to find files fast.

Linux maintains a database of all files on the system that can be quickly searched using locate xyz command, here xyz is the filename you want to find. To locate files faster than run utility updatedb. Run this utility once a week 

How to check free space.

If you want to check the amount of free disk space on your hard disk, use command df, df stands for disk free. If you want to check space taken by particular directory use du /directory. Use different parameters for other options like using du -s filename will check a space taken by a file. 

How to see help.

If you are looking for help, there are lot of documentation provided, use command man . Man stands for manual. 

Switch between different login ids.

To switch between different login ids use Alt + F1, Alt + F2, Alt + F3, Alt + F4 by this you can log as 4 different users. And if you want ot login as superuser in between then use command su and enter password. And to exit from super user id use exit.

 How to change password.

The easiest way to change password is by using command passwd. If you want to change password for the current login id, then use passwd and press enter. It will ask your new password. But if you are changing password of another user then use passwd login_name.To do this login as root. 

How to find disk errors.

You can check for disk errors by using utility fsck, FileSystem Check. Lost clusters are stored in /lost+found directory. 

How to boot two or more operating system.

If you have two operating system eg. Windows Me, Dos 6.22, Linux. And are not able to use LILO or ntldr, then you can use any third- party bootloader software eg.XOSL. 

Error installing linux Boot Partition too big.

This error comes when hard disk size is too big. Solve this problem by making / boot partition in first 8 GB of hard disk. 

How to add a new user.

The easiest way to create a user is by using useradd, here login name is the name which is used by the user. To do this login as root. 

Do you want to change Swap Space without repartitioning.

If you want to increase Swap Space but do not want to repartition or reinstall Linux then follow steps 
by using command dd create a file of 64 MB.

dd if=/dev/zero of=/FileName bs=1024 count=65536.. By this command you create a file with file name FileName.

Initialize it 
mkswap /FileName 65536 sync

Now add this space
swapon /FileName

The drawback of this method is that you are swapping this file every time you start your computer. 

Do you have memory problem during start up.

When the LILO boot prompt, type linux mem=xxxM
here xxx=size of your RAM. 

Familiar with Norton Commander of DOS then try using Midnight Commander.

If you are a new user of Linux and have worked in Norton Commander of DOS then try working on Midnight Commander. It will give you the same feeling of Norton Commander. Command mc

Want to remove LILO from MBR.

Assuming that you have already remove linux partition from hard disk and want to remove LILO boot, boot from DOS disk and run fdisk /mbr, this will restore your boot record. 

Want to configure your Sound Card.

If you want to configure your sound card use utility sndconfig

Want to boot linux from Windows 9x.
Copy the utility dosutils in your hard disk which you can access from Windows. These dosutils comes with mostly all distribution of linux. You can find dosutils in Linux CD. In dosutils folder you will find a batch file. Edit it .

loadlin drive:\boot.img image folder root=/dev/hdxy linux boot partition ro read only. 

Mount a file system.

To mount a file system, use command mount -a [-rw] [-t vfstype]
-a :: Mounts all file systems in /etc/fstab. 
-r :: mounts the file system in Read only mode.
-w :: mounts the file system in Read \ Write mode.
-t fstype :: indicate the file system type. 

Check the services running.

To check the services running, run the utility chkconfig. For gui users, use ntsysv.Eg.
chkconfig servicename off , use to switch off the service 
chkconfig servicename start , use to start the service 
chkconfig servicename restart , use to restart the service 
chkconfig -status -all , use to check the status of all servies

Increase security by using Firewall.

Linux comes with its own firewall system iptables. It is a 2.4 kernel feature, which was earlier known as ipchains.Eg.iptables -L. 

Getting problem during ssh authentication

If you are getting problem in ssh autnetication try, editingfile /etc/ssh/sshd_config and set PasswordAuthentication to yes

Change the boot process.

If you use LILO boot and want to change default boot sequence between linux and dos (assuming the name given to other operating system is Dos and your default boot item is linux) use command lilo -D dos.To do this login as root.