Some more commands in Linux : who, cal, banner, touch - STUDY NOTES

Post Top Ad

Some more commands in Linux : who, cal, banner, touch

who command

The who command prints information about all users who are currently logged in.

The basic who command with no command-line arguments shows the names of users that are currently logged in, and depending on which Unix/Linux system you are using, may also show the terminal they're logged in on, and the time they logged in.

Syntax

The basic syntax is as follows:

Who

Displays the username, line, and time of all currently logged-in sessions. For example:

 

who am i

Displays the same information, but only for the terminal session where the command was issued, for example:

alan     pts/3        2013-12-25 08:52 (:0.0)

who [options] [File]

 

Options

-a--all
The -a argument of the who command lists all available output for each user on your system.
-b--boot
Display the time of the last system boot.
-d--dead
Display dead processes.
-H--heading
Print a line of column headings.
--ips
Print IP addresses instead of hostnames. With --lookup, canonicalizes based on stored IP, if available, rather than stored hostname.
-l--login
Print system login processes.
--lookup
Attempt to canonicalize hostnames via DNS.
-m
Only print information about the user and host associated with standard input (the terminal where the command was issued). This method adheres to the POSIX standard.
-p--process
Print active processes spawned by init.
-q--count
Displays all login names, and a count of all logged-on users.
-r--runlevel
Print the current runlevel.
-s--short
Print only name, line, and time fields, which is the default.
-t--time
Print the last time the system clock was changed, if the information is available.
-T-w--mesg
Add a character which indicates the state of the terminal line: "+" if the terminal is writable, "-" if it is not, or "?" if a bad line is encountered.
-u--users
Print the idle time for each user, and the process ID.
--message
Same as -T.
--writable
Same as -T.
--help
Display a help message, and exit.
--version
Display version information, and exit.



who | grep 'userNameHere'

This command is use to find the particular user.

Linux Command - cal

Cal displays a simple calendar. 

cal syntax

cal [options] [[[day] month] year]

Options
-1
Display a single month, which is the default setting.
-3
Display three months: last month, this month, and next month.
-s
Display the calendar using Sunday as the first day of the week.
-m
Display Monday as the first day of the week.
-j
Display dates of the Julian calendar.
-y
Display a calendar for the entire current year.

cal examples

 If arguments are not specified, the current month is displayed

cal

Displays the calendar for this month.

cal 12 2000

Displays the calendar for December of the year 2000.

To display complete year calendar.

cal –y

banner command

'banner' is a command which prints a high resolution text banner on the system console or if you have a printer connected to your machine, you can redirect the output to the printer. 

For example,

$ banner -w 50 Ravi

The above command will print the name on the console with a width of 50 characters. If the -w option is omitted, it prints the name in the default width of 102 characters. The character used to print the name is '#'.

 

You can also redirect the output to a printer as follows:


$ banner -w 60 Ravi > /dev/lp0



The touch Command

The touch command is the easiest way to create new, empty files. It is also used to change the timestamps (i.e., dates and times of the most recent access and modification) on existing files and directories.

touch's syntax is

touch [option] file_name(s)

When used without any options, touch creates new files for any file names that are provided as arguments (i.e., input data) if files with such names do not already exist. Touch can create any number of files simultaneously.

Thus, for example, the following command would create three new, empty files named file1, file2 and file3:
touch file1 file2 file3



https://books2notes.blogspot.in/p/linux-startup-shutdown-process.htmlhttps://books2notes.blogspot.in/p/linux-print-command.html

No comments:

Post a Comment

Post Bottom Ad