Unix Commands Part 8

System Status

at, chmod,chgrp, chown,crontab,date, df,du, env, finger, ps,ruptime, shutdwon,stty, who.


At command.
at command along with crontab command is used to schedule jobs.
at options time [ddate] [+increment] is syntax of at command.
for example if I have a script named usersloggedin which contains.

 #!/bin/ksh who | wc -l echo "are total number of people logged in at this time."
and I want to run this script at 8:00 AM. So I will first type at 8:00 %lt;enter>
usersloggedin %lt;enter>
I will get following output at 8:00 AM
      30 are total number of people logged in at this time.
    Options:
  • -f file will execute commands in a file.
  • -m will send mail to user after job is completed.
  • -l will report all jobs that are scheduled and their jobnumbers.
  • -r jobnumber will remove specified jobs that were previously scheduled.

Chmod command.
chmod command is used to change permissions on a file.
for example if I have a text file with calender in it called cal.txt.
initially when this file will be created the permissions for this file depends upon umask set in your profile files. As you can see this file has 666 or -rw-rw-rw attributes.

ls -la cal.txt

-rw-rw-rw- 1 ssb dxidev 135 Dec 3 16:14 cal.txt

In this line above I have -rw-rw-rw- meaning respectively that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next ssb is owner of this file dxidev is the group of this file, there are 135 bytes in this file, this file was created on December 3 at time16:14 and at the end there is name of this file. Learn to read these permissions in binary, like this for example Decimal 644 which is 110 100 100 in binary meand rw-r--r-- or user can read,write this file, group can read only, everyone else can read only. Similarly, if permissions are 755 or 111 101 101 that means rwxr-xr-x or user can read, write and execute, group can read and execute, everyone else can read and execute. All directories have d in front of permissions. So if you don't want anyone to see your files or to do anything with it use chmod command and make permissions so that only you can read and write to that file, i.e.
chmod 600 filename.


Chgrp command.
chgrp command is used to change the group of a file or directory.
You must own the file or be a superuser.
chgrp [options] newgroup files is syntax of chgrp.
Newgroup is either a group Id or a group name located in /etc/group .

    Options:
  • -h will change the group on symbolic links.
  • -R recursively descend through directory changing group of all files and subdirectories.

Chown command.
chown command to change ownership of a file or directory to one or more users.
Syntax is
chown options newowner files

    Options
  • -h will change the owner on symbolic links.
  • -R will recursively descend through the directory, including subdirectories and symbolic links.

Crontab command.
crontab command is used to schedule jobs. You must have permission to run this command by unix Administrator. Jobs are scheduled in five numbers, as follows.

 Minutes   0-59     Hour      0-23     Day of month 1-31     month   1-12     Day of week  0-6 (0 is sunday) 
so for example you want to schedule a job which runs from script named backup_jobs in /usr/local/bin directory on sunday (day 0) at 11.25 (22:25) on 15th of month. The entry in crontab file will be. * represents all values.
 25 22  15 * 0 /usr/local/bin/backup_jobs 
The * here tells system to run this each month.
Syntax is
crontab file So a create a file with the scheduled jobs as above and then type
crontab filename .This will scheduled the jobs.

Date command.
Date displays todays date, to use it type date at prompt.

Sun Dec  7 14:23:08 EST 1997 
is similar to what you should see on screen.

Df command.
df command displays information about mounted filesystems. It reports the number of free disk blocks. Typically a Disk block is 512 bytes (or 1/2 Kilobyte).
syntax is
df options name

    Options
  • -b will print only the number of free blocks.
  • -e will print only the number of free files.
  • -f will report free blocks but not free inodes.
  • -F type will report on an umounted file system specified by type.
  • -k will print allocation in kilobytes.
  • -l will report only on local file systems.
  • -n will print only the file system name type, with no arguments it lists type of all filesystems

Du command.
du command displays disk usage.


Env command.
env command displays all the variables.


Finger command.
finger command.


PS command
ps command is probably the most useful command for systems administrators. It reports information on active processes.
ps options

    options.
  • -a Lists all processes in system except processes not attached to terminals.
  • -e Lists all processes in system.
  • -f Lists a full listing.
  • -j print process group ID and session ID.

Ruptime command.
ruptime command tells the status of local networked machines.
ruptime options

    options.
  • -a include user even if they've been idle for more than one hour.
  • -l sort by load average.
  • -r reverse the sort order.
  • -t sort by uptime.
  • -i sort by number of users.

Shutdown command.
Shutdown command can only be executed by root. To gracefully bring down a system, shutdown command is used.

    options.
  • -gn use a grace-period of n seconds (default is 60).
  • -ik tell the init command to place system in a state k.
    • s single-user state (default)
    • 0 shutdown for power-off.
    • 1 like s, but mount multi-user file systems.
    • 5 stop system, go to firmware mode.
    • 6 stop system then reboot.
  • -y suppress the default prompt for confirmation.

Stty command
stty command sets terminal input output options for the current terminal. without options stty reports terminal settings.
stty options modes <>

    options
  • -a report all options.
  • -g report current settings.
    Modes
  • 0 hang up phone.
  • n set terminal baud.
  • erase keyname, will change your keyname to be backspace key.

Who command
who command displays information about the current status of system.
who options file
Who as default prints login names of users currently logged in.

    Options
  • -a use all options.
  • -b Report information about last reboot.
  • -d report expired processes.
  • -H print headings.
  • -p report previously spawned processes.
  • -u report terminal usage.


Comments

Popular posts from this blog

Linux File and Directory Permissions

How to Disable SSL for Webmin

INSTALL CISCO VPN CLIENT ON WINDOWS 10 (32 & 64 BIT). FIX REASON 442