skip to main | skip to sidebar

Linux Tutorial for Beginners

Pages

  • Home
 
  • RSS
  • Twitter
Showing posts with label Linux Commands. Show all posts
Showing posts with label Linux Commands. Show all posts
Friday, February 17, 2012

ls command

Posted by Raju Gupta at 1:28 AM – 0 comments
 

About ls
Lists the contents of a directory.

Syntax
ls [Option] [pathnames]

Option
-a
Shows you all files, even files that are hidden (these files begin with a dot.)

-A
List all files including the hidden files. However, does not display the working directory (.) or the parent directory (..).

-b
Force printing of non-printable characters to be in octal \ddd notation.

-c
Use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).

-C
Multi-column output with entries sorted down the columns. Generally this is the default option.

-d     
If an argument is a directory it only lists its name not its contents.

-f      
Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.

-F
Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals sign (=).

-g
Same as -l except the owner is not printed.

-I
For each file, print the i-node number in the first column of the report.

-l
Shows you huge amounts of information (permissions, owners, size, and when last modified.)

-L
If an argument is a symbolic link, list the file or directory the link references rather than the link itself.

-m
Stream output format; files are listed across the page, separated by commas.

-n
The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the associated character strings.

-o
The same as -l, except that the group is not printed.

-p
Displays a slash ( / ) in front of all directories.

-q
Force printing of non-printable characters in file names as the character question mark (?).

-r
Reverses the order of how the files are displayed.

-R
Includes the contents of subdirectories.

-s
Give size in blocks, including indirect blocks, for each entry.

-t
Shows you the files in modification time.

-u
Use time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).

-x
Displays files in columns.

-1
Print one entry per line of output.

[ Read More ]
Read more...
Wednesday, February 15, 2012

Linux chkconfig Command Examples

Posted by Raju Gupta at 4:39 AM – 0 comments
 

Linux chkconfig Command Examples  Add, Remove, View, Change Services

Chkconfig command is used to setup, view, or change services that are configured to start automatically during the system startup.

1. Check Service Startup status from Shell Script

When you execute chkconfig command only with the service name, it returns true if the service is configured for startup. The following code snippet shows how to check whether a service is configured for startup or not from a shell script.

# vi check.sh
chkconfig network && echo "Network service is configured"
chkconfig junk && echo "Junk service is configured"

# ./check.sh
Network service is configured

You can also specifically check whether it is configured for a particular run level or not.

# vi check1.sh
chkconfig network --level 3 && echo "Network service is configured for level 3"
chkconfig network --level 1 && echo "Network service is configured for level 1"

# ./check1.sh
Network service is configured for level 3

2. View Current Status of Startup Services

The
�list option displays all the services with the current startup configuration status.

# chkconfig --list
abrtd   0:off   1:off   2:off   3:on    4:off   5:on    6:off
acpid   0:off   1:off   2:off   3:off   4:off   5:off   6:off
atd     0:off   1:off   2:off   3:on    4:on    5:on    6:off

To view only the services that are configured to be started during system startup, do the following. Please note that this assumes that your system startup level is 3.

chkconfig --list | grep 3:on

[ Read More ]
Read more...
Monday, January 23, 2012

Some basic and common Commands in Linux

Posted by Raju Gupta at 6:12 AM – 0 comments
 
Some basic and common Commands
# cd - * Go to previous directory
# cd * Go to $Home directory
# (cd <dir> && <command> ) * Go to dir, execute command and return to current dir
# ls * Lists the contents of a Directory
# pwd * Display Current Directory
# cal * Display calendar.
# cat * The cat command reads one or more files and prints them to standard output.
# wc * Display Number of line, words, bytes.
# tty * Print the file name of the terminal connected to standard input synopsis.
# passwd * Changing the password or user.
# bc * Basic calculator language. ( For exit use Ctrl+d )
# mkdir * Make Directory
# rmdir * Remove empty directory
# cp * copy files and directory.
# rm * Deleting filename
# mv * move or rename files
# od * Dump file in octal and other formats

# which <command > * Show full path name of command
# time < command > * See how long a command takes.
# time cat * Start stopwatch. Ctrl-d to stop. See also sw
#tar -cvf <filename.tar> <source> * Create a backup file.
#tar -xvf <filename.tar> * Restore backup file.
#gzip <filename.tar> * Create compress file
#unzip <filename.tar.gz> * Restore compress file
#bzip2 <filename.tar> * Create compress file.
#bunzip2 <filename.bz2> * Restore compress file
# man -t ls | ps2pdf - > ls.pdf * make a pdf file of a manual page.
# gpg -c < file name > * Encrypt file
# gpg <file-name.gpg> * Decrypt file
# ethtool eth0 * Show status of Ethernet interface eth0
# iwconfig eth1 * show status of wireless interface eth1
# iwlist * scan list wireless networks in range
# ip link show * list network interface
# ip link set dev eth0 * name wan Rename interface eth0 to wan
# ip link set dev eth0 up * Bring interface eth0 up (or down)
# ip addr show * List addresses for interfaces
# ip route show * List routing table
# ip route add default via 1.2.3.254 * Set default gateway to 1.2.3.254
# host pixelbeat.org * Lookup DNS ip address for name or vice versa
# netstat -tupl * List internet services on a system
# netstat -tup * List active connections to/from system
# tail -f /var/log/messages * Monitor messages in a log file
# tcpdump not port 22 * Show network traffic except ssh.
# uname -a * Show kernel version and system architecture
# cat /proc/partitions * Show all partitions registered on the system
# grep MemTotal /proc/meminfo * Show RAM total seen by the system
# grep "model name" /proc/cpuinfo * Show CPU(s) info
[ Read More ]
Read more...
Sunday, January 22, 2012

Fun with linux commands

Posted by Raju Gupta at 11:08 PM – 0 comments
 
Try Ctrl+e to move to the end of the command string and Ctrl+a to reach start. It’s the fastest way to edit a Linux command line. To delete a word in the command string, use Ctrl+w.
Another wonder of a simple shell variable is !$. Let’s say you have to create a directory, go into it and then rename it. So the flow of commands would be:

$ mkdir your_dir
$ mv your_dir my_dir
$ cd my_dir
Well, Linux has a shorter and quicker way:
$ mkdir your_dir
$ mv !$ my_dir
$ cd !$
!$ points to the last string in the command string. This is useful in various scenarios where the last word of command string is to be used in subsequent commands (almost with all Linux commands like vi, tar, gzip, etc).


Do you want to know what an ls or a date command does internally? Just run the following code to get to know the basic block of any Linux command:
$ strace -c /usr/bin/ls
strace is a system call monitor command and provides information about system calls made by an application, including the call arguments and return value.
What if you want to create a chain of directories and sub-directories, something like /tmp/our/your/mine?
Try this:
 $ mkdir -p /tmp/our/your/mine

One very interesting way to combine some related commands is with &&.
$ cd dir_name && ls -alr && cd ..

Now for some fun! Have you ever tried checking the vulnerability of your Linux system? Try a fork-bomb to evaluate this:
$ :(){ :|: & };:

It’s actually a shell function; look closely and it’s an unnamed function :() with the body enclosed in {}. The statement ‘:|:’ makes a call to the function itself and pipes the output to another function call—thus we are calling the function twice. & puts all processes in the background and hence you can’t kill any process. Finally ‘;’ completes the function definition and the last ‘:’ initiates a call to this unnamed function. So it recursively creates processes and eventually your system will hang. This is one of the most dangerous Linux commands and may cause your computer to crash!

Remedy: How to avoid a fork bomb? Of course, by limiting the process limit; you need to edit /etc/security/limits.conf. Edit the variable nproc to user_name hard nproc 100. You require root privileges to modify this file.
One more dirty way to hack into the system is through continuous reboots, resulting in the total breakdown of a Linux machine. Here’s an option that you need root access for. Edit the file /etc/inittab and modify the line id:5:initdefault: to id:6:initdefault:. That’s all! Linux specifies various user modes and 6 is intended for reboot. Hence, your machine keeps on rebooting every time it checks for the default user mode.

Remedy: Modify your Grub configuration (the Linux bootloader) and boot in single user mode. Edit the file /etc/inittab and change the default user level to 5.
[ Read More ]
Read more...
Older Posts
Subscribe to: Posts (Atom)

Our Blogs

  • Java Programs with Output
  • C Programming Tutorial
  • Language Tutorial
  • Android Development Tutorial
  • Web Development Tutorial
  • Popular
  • Recent
  • Archives

Popular Posts

  • Apache Configuration File Security Option
    you’ll examine the security options available in the main Apache configuration file, httpd.conf. That file can be modified to secure the e...
  • AWS VPC Overview
    What is VPC ? A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other vir...
  • Advantages & Disadvantages of Kerberos
    Advantages of Kerberos Most conventional network services use password-based authentication schemes. Such schemes require a user to au...
  • SSH login without password
    The following steps can be used to ssh from one system to another without specifying a password: 1. On the client run the following com...
  • Apache Installation and Configuration through source code
    In this example we extract the source code to a directory under /usr/local/src/ cp httpd-2.0.46.tar.gz /usr/local/src cd /usr/local/src...
  • How to automatically chroot jail selected ssh user logins
    1. Creating basic chroot environment First we need to create a simple chroot environment. Our chroot environment will consist of a bash she...
  • How to Create the Kerberos database
    Create the database with the following command.  [root@coma ~] kdb5_util create -s This will prompt you for a password. You will ...
  • Kerberos and PAM
    Kerberos-aware services do not currently make use of Pluggable Authentication Modules (PAM) — these services bypass PAM completely. However...
  • Apache and SELinux File Labels
    Take a look at the SELinux settings associated with Apache. To review, SELinux settings, as they relate to a service, mostly fall into tw...
  • History of MINIX 3
    MINIX has a long history. It goes back to 1987 when the first edition of the book Operating Systems: Design and Implementation by Andrew S...
Powered by Blogger.

Archives

  • ▼  2014 (1)
    • ▼  May (1)
      • AWS VPC Overview
  • ►  2013 (4)
    • ►  February (4)
  • ►  2012 (89)
    • ►  November (1)
    • ►  March (4)
    • ►  February (36)
    • ►  January (48)
 

Followers

Labels

  • Apache (8)
  • aws (1)
  • Bridge (1)
  • cloud computing (1)
  • Configuration (1)
  • dhcp server (7)
  • DNS (8)
  • File system (11)
  • Fping (1)
  • Iptable basic (3)
  • KDC slave server (1)
  • Kerberos (14)
  • kerberos configuration (5)
  • kerberos database (1)
  • LaTeX (1)
  • Ldap basic (2)
  • Linux aliases (1)
  • Linux Commands (4)
  • Linux History (2)
  • Linux Installation (3)
  • Linux kernel (3)
  • Linux shell (2)
  • Linux software (2)
  • Lvm (1)
  • Mail Server (3)
  • Network Script (1)
  • PHP (1)
  • Raid (6)
  • SELinux (1)
  • Sendmail (3)
  • ssh (2)
  • Tcpdump example (1)
  • Virtualization (5)
  • Webmin (1)
  • Yum (2)
 
 
© 2011 Linux Tutorial for Beginners | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger