Home » 2014 » February » 19 » Some unique and special commands in Linux

12:06 PM
Some unique and special commands in Linux
Lets see some unique  and important commands in Linux operating system
Click on a command to expand/collapse

rcp

This command is used to copy files remotely from one machine to another.
DESCRIPTION
Rcp copies files between machines. Each file or directory argument is either a remote file name of the form ``rname@rhost:path'', or a local file name (containing no `:' characters, or a `/' before any `:'s).

SCP

scp is a program used to copy files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1).  Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
 
Formate:  scp [[username]@host1]:file1 [[username]@remote-host2]:[dir]

For eg. To copy a file from your system to any other system, use below command

user1@host1:~> scp abc1.txt host2:~/test
Enter Your Windows Password:
abc1.txt                                                                                            100%   19     0.0KB/s   00:00

The above command will copy the file abc1.txt of home directory of host1 to the ~/test directory of host2
If you dont specify any directory on the destination host, the file will be copied to home directory of remote host. Lets say: See below command:
 
user1@host1:~> scp abc1.txt host2:

Enter Your Windows Password:
abc1.txt                                                                                            100%   19     0.0KB/s   00:00

Printer related commands

lp

This command is used to send jobs for printing. If no printer specified, it will use the default destination. DESCRIPTION
lp submits files for printing or alters a pending job. Use a filename of "-" to force printing from the standard input. The format is:
SYNOPSIS
lp [ -E ] [ -c ] [ -d destination ] [ -h server ] [ -m ] [ -n num-copies [ -o option ] [ -q priority ] [ -s ] [ -t title ] [ -H handling ] [ -P page-list ] [ file(s) ] Eg. Prompt:> lp abc.txt {ENTER} The file abc.txt will be sent for printing to the default printer
You can use -d destination to specify the destination printer -h hostname
Specifies the print server hostname. The default is "localhost" or the value of the CUPS_SERVER environment variable.

lpr

Same as lp, It also sends jobs for printing, if no destination specified, it used the default destinations.

Format:
lpr [ -E ] [ -P destination ] [ -U username ] [ -# num-copies [ -l ] [ -o option ] [ -p] [ -r ] [ -C/J/T title ] [file(s) ]

DESCRIPTION
lpr submits files for printing. Files named on the command line are sent to the named printer (or the system default destination if no destination is specified). If no files are listed on the command-line lpr reads the print file from the standard input.

lpadmin


This command configure cups printers and classes
Format:
lpadmin [ -E ] [-U username ] [ -h server[:port] ] -d destination
lpadmin [ -E ] [-U username ] [ -h server[:port] ] -p printer option(s)
lpadmin [ -E ] [-U username ] [ -h server[:port] ] -x destination

DESCRIPTION
lpadmin configures printer and class queues provided by CUPS. It can also be used to set the server default printer or
class.
Example:
lpadmin -U user1 -h cups-server:portno -p printer1 -v lpd://remoteserver/printer1 -o printer-is-shared=false -o printer-error-policy=retry-job -E
lpadmin -U user1 -h cups-server:port -p printer2 -v lpd://remote-server/printer2 -o printer-is-shared=false -o printer-error-policy=retry-job -E

lpstat

This command shows the status of a CUPS printer.
DESCRIPTION
lpstat displays status information about the current classes, jobs, and printers. When run with no arguments, lpstat will list jobs queued by the current user. -a [printer(s)] Shows the accepting state of printer queues. If no printers are specified then all printers are listed. Eg.
lpstat -a
printer1 accepting requests since Tue 18 Feb 2014 11:15:04 AM CET
printer2 accepting requests since Tue 18 Feb 2014 11:15:01 AM CET
-c [class(es)]
Shows the printer classes and the printers that belong to them. If no classes are specified then all classes are listed.

-d
Shows the current default destination.

-h server[:port]
Specifies an alternate server.

-l
Shows a long listing of printers, classes, or jobs.

-o [destination(s)]
Shows the jobs queue on the specified destinations. If no destinations are specified all jobs are shown.
-r
Shows whether the CUPS server is running.

-s
Shows a status summary, including the default destination, a list of classes and their member printers, and a list of printers and their associated devices.
Eg.
Prompt:>lpstat -s
no system default destination
device for printer1: lpd://server-name/printer1
device for printer2: lpd://server-name/printer2

lpinfo

Thiscommand show available devices or drivers
Format:
 lpinfo [ -E ] [ -U username ] [ -h server[:port] ] [ -l ] -m
 lpinfo [ -E ] [ -U username ] [ -h server[:port] ] [ -l ] -v
DESCRIPTION
lpinfo lists the available devices or drivers known to the CUPS server. The first form (-m) lists the available drivers, while the second form (-v) lists the available devices.

lppasswd

lppasswd - add, change, or delete digest passwords.

Format:
lppasswd [ username ] lppasswd -a [ -g groupname ] username lppasswd -x username
DESCRIPTION

lppasswd adds, changes, or deletes passwords in the CUPS digest password file, passwd.md5. When run by a normal user, lppasswd will prompt for the old and new passwords. When run by the super-user, lppasswd can add new accounts (-a user- name), change existing accounts (username), or delete accounts (-x username) in the digest password file. Digest usernames do not have to match local UNIX usernames.

lpc

lpoptions


ps

This command shows all the currently running processes
DESCRIPTION:
ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead.
 
It shows information in below format:
UID PID PPID C STIME TTY TIME CMD
UID -> User Id of the starter of the process
PID -> Process id of the process
PPID -> Process id of the parent process
C ->
STIME -> start time
TTY
TIME ->Duration by which the process is running
CMD -> The command to start the process
Example:
 
Prompt:>ps -fu userName
This command will list all the process started by "userName"
 
Prompt:>ps -aef
 This command will list all the process started by any user on the Linux machine.
To see the every process on the system using BSD syntax, we can use folowwing command:

ps -aux
ps -ax

man

This command shows a help manual of any other command. It accepts a command-name as argument and shows a detailed help manual on that command.
 
Example:
Prompt:>man top
Prompt:>man man

top

Like ps, top command also shows currently running processes but it also updates their status repeatedly.
Prompt:>top {}
top - 12:59:25 up 82 days, 2:31, 6 users, load average: 0.31, 0.38, 0.36 
Tasks: 257 total, 1 running, 255 sleeping, 0 stopped, 1 zombie 
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st 
Mem: 32782M total, 31096M used, 1685M free, 185M buffers 
Swap: 1027M total, 87M used, 940M free, 26222M cached 
 
It displays following details:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

The command starts a display where all active processes are shown. It keeps on updating the values like % of CPU usage, % of memory usage, time the process is up by etc.

whoami

This command tells you who you are. It will tell the username who is logged on currently. For Eg.
DESCRIPTION
Print the user name associated with the current effective user ID. Same as id -un. Prompt:>whoami{Enter}
user1

xev

This command is ued to log the keyboard events. It starts an event tester and generates a log for evry keys pressed on  the keyboard.

DESCRIPTION
 Xev creates a window and then asks the X server to send it events whenever anything happens to the window (such as it being moved, resized, typed in, clicked in, etc.). You can also attach it to an existing  window. It is useful for seeing what causes events to occur and to display the information that they contain; it is essentially a debugging

and development tool, and should not be needed in normal usage.
For eg. Below is the log of Shift key and Enter key. Notice the 3rd line which gives the keycode , the key pressed and the screen where pressed. 


KeyPress event, serial 23, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 759929, (601,628), root:(605,654),
  state 0x0, keycode 61 (keysym 0xffe2, Shift_R), same_screen YES,
  XLookupString gives 0 bytes:
  XmbLookupString gives 0 bytes:
  XFilterEvent returns: False

KeyRelease event, serial 25, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 760088, (601,628), root:(605,654),
  state 0x1, keycode 61 (keysym 0xffe2, Shift_R), same_screen YES,
  XLookupString gives 0 bytes:
  XFilterEvent returns: False

KeyPress event, serial 25, synthetic NO, window 0x400001,
 root 0x54, subw 0x0, time 761329, (601,628), root:(605,654),
 state 0x0, keycode 35 (keysym 0xff0d, Return), same_screen YES,
 " XLookupString gives 1 bytes: (0d) "
 " XmbLookupString gives 1 bytes: (0d) "
  XFilterEvent returns: False

KeyRelease event, serial 25, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 761469, (601,628), root:(605,654),
  state 0x0, keycode 35 (keysym 0xff0d, Return), same_screen YES,
 " XLookupString gives 1 bytes: (0d) "

  XFilterEvent returns: False

xmodmap

This  command is used to remap the keyboard keys from one to another or as per user's choice. Suppose your Enter key is not working, you can use your right shift key by mapping Enter key to the it.

DESCRIPTION
 The xmodmap program is used to edit and display the keyboard modifier
  map and keymap table that are used by client applications to convert
  event keycodes into keysyms. It is usually run from the user's session 
startup script to configure the keyboard according to personal tastes.
 
So to map the right shift key to your enter key, use below command:
 xmodmap -e "keycode 61=Return"
 xmodmap -e "keycode 35=Shift_R"
 
 The format is: xmodmap -e EXPRESSION. The expression can be:
 keycode NUMBER=KEYSYMNAME
 
This mapping will persist only in the logged session, if you want it make it permanent, you have to execute below command.
 
xmodmap -pke >~/.Xmodmap
It will create a file Xmodmap in your home directory.
Then create one more file called .xinitrc in your home directory where you have to enter this line:
 xmodmap .Xmodmap

ping

This command is used to ping an ip-address or server to find if the host is in the n/w or reachable. It takes ip address or ip-name as argument.
DESCRIPTION:
   
       ping  uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.
 
      On success:

    Linux-Prompt:> ping serverOrIP
    PING serverOrIP (1.2.3.4) 56(84) bytes of data.
    64 bytes from serverOrIP (1.2.3.4): icmp_seq=1 ttl=58 time=0.365 ms
    64 bytes from serverOrIP (1.2.3.4): icmp_seq=2 ttl=58 time=0.435 ms
    64 bytes from serverOrIP (1.2.3.4): icmp_seq=3 ttl=58 time=0.345 ms


    --- serverOrIP ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2005ms
    rtt min/avg/max/mdev = 0.345/0.381/0.435/0.044 ms
     
    On failure:
    It says: Unknown host or ping failure.

    netstat

    The command shows all the active internet connection.
    DESCRIPTION:
           Netstat  prints  information  about the Linux networking subsystem.  The type of information printed is controlled by  the first argument, as follows:
       (none)
    By default, netstat displays a list of open sockets.  If you don't specify any  address  families,  then  the  active sockets of all configured address families will be printed.
    It shows following information:

    Proto Recv-Q Send-Q Local Address           Foreign Address         State


    nmap

    The command accepts ip-address or Ip-name as argument. It is used to show the status of all open ports on that IP-address.
     
    DESCRIPTION
           Nmap ("Network Mapper") is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.
    Eg.
    Prompt:>nmap ServerOrIP
    Starting Nmap 4.75 ( http://nmap.org ) at 2014-02-20 11:41 CET
    Interesting ports on ServerOrIP (10.252.103.22):
    Not shown: 991 closed ports

    PORT      STATE SERVICE
    25/tcp    open  smtp
    80/tcp    open  http
    139/tcp   open  netbios-ssn
    443/tcp   open  https
    515/tcp   open  printer
    631/tcp   open  ipp
    843/tcp   open  unknown
    9100/tcp  open  jetdirect
    50003/tcp open  unknown
    Nmap done: 1 IP address (1 host up) scanned in 6.61 seconds

    ssh

    history

    This command displays a list of recently executed commands on your session with the timestamp.
    Eg.
    Prompt:>history
    1  2014-02-20 15:25:18 netstat
    2  2014-02-20 15:29:51 man history
    3  2014-02-20 15:30:28 history
    In your home directory, there is a file .bash_history which contains all the recently executed commands.

     

    chmod

    The commands is used to change access permission to a file. I can add access permission, remove access permissions.
    Refer below example:
     
    Prompt:>ls -l abc.txt
    -rw-rw-r-- 1 someUser someGroup 27 2014-02-20 15:37 abc.txt
    Prompt:>chmod 777 abc.txt
    Prompt:>ll abc.txt
    -rwxrwxrwx 1 someUser someGroup 27 2014-02-20 15:37 abc.txt
    User someUser had permission -rw-rw-r--(664) on the file abc.txt by default.

                           Chmod changes the file permission to 777 i.e. -rwxrwxrwx

                    chown

                    This command changes the group and owneship of a file
                    Description:
                    chown changes the user and/or group ownership of each given file. If only an owner (a user name or numeric user ID) is given, that user is made the owner of each given file, and the files' group is not changed. If the owner is followed by a colon and a group name (or numeric group ID), with no spaces between them, the group ownership of the files is changed as well.
                     
                    Examples:
                    chown root /mydir             Change the owner of /mirdir to "root".
                    chown root:shan /mydir It will also do the same, but also change its group to "staff".
                    chown -hR root /mydir Change the owner of /mydir and subfiles to "root".
                    • xeyes

                      This command starts a funny animation. It  will start a small window containing animation of eyes. And, the eyes will look where your cursor goes. To quit press ctrl+c .

                      • emacs 
                       

                      info

                      This command is used to read a documentation in info format.
                      Example
                      Prompt:>info emacs  {ENTER}
                      Prompt:>info show top-level dir menu
                       
                      At the info page, press
                      p -> to go to previous node(data)
                      n -> to the nest node or entry
                      spacebar -> to go below. The last two lines of the content will be at the top of the page and more lines will be displayed.
                      del/backspace ->  to come back (undo of spacebar)
                       
                       
                      • portmap
                       

                      file

                      A command to determine the type of file. It takes a file as argument and tells its type
                      DESCRIPTION
                           file tests each argument in an attempt to classify it.  There are three sets of tests, performed in this order: filesystem tests, magic tests, and language tests.  The first test that succeeds causes the file type to be printed.
                      Eg.

                      Prompt:>file abc.txt 
                      abc.txt: ASCII text 
                      Prompt:> file abc.xml 
                      abc.xml: XML 
                      Prompt:>ll LinkFile 
                      lrwxrwxrwx 1 username group 44 2013-08-01 09:39 LinkFile -> ~/a/b/c/somescript.sh 
                      Prompt:>file LinkFile 
                      LinkFile: symbolic link to `~/a/b/c/somescript.sh'
                       

                      type

                      This command accepts the command-name as argument and tells the type of command. It writes about the command like it is a shell builtin command or an alias or a bin command.
                      Eg. 
                      Prompt:> type alias
                      alias is a shell builtin
                       
                      Prompt:> type whoami
                      whoami is /usr/bin/whoami

                      Prompt:> type ll

                       

                      ll is aliased to `ls -la'
                       

                      alias

                      A shell builtin command that shows aliases being used currently in your system.
                      You can set aliases as per need to shorten the long commands and customize the commands. For Eg.
                      alias ll='ls -l'
                      It will set "ls -l" command to "ll" and "ll " will work as "ls -l"
                      To set an alias, use below format:
                      alias customCommand='complex set of comands'
                       

                      nslookup

                      It takes server-name or ip-address as argument. This command is used to query the DNS and find the alias names of a server. It gives all the canonical and logical names and ip-address for a server or ip-adress.
                       
                      Description:Nslookup is a program to query Internet domain name servers.  Nslookup
                             has two modes: interactive and non-interactive. Interactive mode allows
                             the user to query name servers for information about various hosts and
                             domains or to print a list of hosts in a domain. Non-interactive mode
                             is used to print just the name and requested information for a host or
                             domain.
                      Eg. nslookup ip-address/server
                       

                      host

                      Takes server/ip-name as argument.This command will tell you the alias name and ip- address of the server-name
                      DESCRIPTION:
                             host is a simple utility for performing DNS lookups. It is normally
                             used to convert names to IP addresses and vice versa.
                       

                      uname

                      It displays system information.
                      "uname -a" will give a long system description.
                      Eg. Prompt:>uname -a

                      Linux hostname 2.6.32.59-0.3-xen #1 SMP 2012-04-27 11:14:44 +0200 x86_64 x86_64 x86_64 GNU/Linux

                       

                      finger

                      DESCRIPTION
                           The finger utility displays information about local and remote system users.  By default, the following information is displayed about each user currently logged-in to the local host:
                                 ·   login name
                                 ·   user's full name
                                 ·   associated terminal name
                                 ·   idle time
                                 ·   login time
                                 ·   from where


                       

                      id

                      This command is used to find the user id and group id of a user. It also shows the groups the user belongs to.
                      Eg. Prompt:>id
                      uid=12345(someid) gid=12345(groupname) groups=gid(gname), gid(gname)...
                     
                     

                    Category: Open System-Linux | Views: 3221 | Added by: shanky | Tags: linux commands, commands in linux, xmodmap, chmod, special commands in linux, unix commands, basic commands in unix, netstat, xev | Rating: 0.0/0

                    Related blogs


                    You may also like to see:


                    [2016-04-14][Open System-Linux]
                    AT command in Linux : schedule a task at later time
                    [2014-05-22][Open System-Linux]
                    Archiving and compression of files in Linux
                    [2014-06-05][Open System-Linux]
                    SCRIPT command: Save your Linux sessions automatically
                    [2016-03-17][Open System-Linux]
                    Some amazing command shortcuts in Linux
                    [2016-05-24][Open System-Linux]
                    FACTER command in Linux : showing system facts

                    Total comments: 0
                    ComForm">
                    avatar