Welcome, Guest: Join Kenyans247 Log In!

Stats: 279 Members, 13,152 topics and 65 posts Date:  Monday 10 August 2020 at 04:32 AM
Popular & Trending NewestFeatured Links ClassifiedDirectoryLivescoresLive Kenyan TVLive Kenyan Radio Follow Us Like Us

About Us Terms & Conditions Privacy Policy FAQ's Disclaimer Copyright Contact Us Advertise With Us Download K247 APP Marketplace Moderator Policy We Are Hiring Kenya Radio and TV Stations Listen and Watch Live Letter From the C.E.O Kenya Radio Stations Live Kenya TV Stations Live Kenya - Newspapers and News Sites and popular blog Forum Rules

How to Use the Linux type Command

Kenyans247 / Science/Technology / Phones / How to Use the Linux type Command

119 people viewed

How To Check Your Loan Limit Kcb How To Report A Fake Business Listing On Google Maps How To Apply For Original Land Title Deed In Kenya How To Power Off Your Samsung Galaxy Note 10 Or 10 Plus
(Go Down) (» Reply topic)
How to Use the Linux type Command by Kenyans247(1): Fri Jul 2019 11:28pm
Find out if a command resolves to an alias, a disk file, a shell function, a built-in command, or a reserved word. Use type to discover how your Linux commands are executed and understand your system better.



Do My Bidding
When we open a terminal window and start issuing commands to our Linux computer, we rarely stop to think what software components within the operating system are reacting to our commands and carrying them out for us. We type the command, get the result, and move on with our workload.

Knowing how the commands are carried out gives us a better understanding of the way our Linux or other Unix-like operating system is constructed. Having a peek beneath the hood can make us a more informed driver.

The instructions we issue to the command line are in one of the following categories:

Alias: A user (or system) defined command that causes other, usually long-winded or complex, command sequences to take place.
Disk file: A binary executable file, such as /usr/bin/top.
Shell function: A user (or system) defined function that can be used on the command line or included in scripts.
Builtin command: A command that is carried out by the shell itself, such as pwd.
Reserved word: A word that is reserved by the shell such as if and elif. They are also called keywords.
The type command tells us which category any of the Linux commands belongs to. Here’s a quick tutorial to understanding the command’s output.

The type Command
Let’s rattle through some quick examples, for each of the command categories.

type date
type date in a terminal window

The date command is an executable disk file.

type ls
type ls in a terminal window

The ls command is an alias, wrapping the underlying ls command to use the --color=auto option by default.

type lowdown
type lowdown in a terminal window

The lowdown command is a user-defined function that was set up on the commuter used to research this article. It provides a quick snapshot of some system resources. It is a combination of whoami , w , free and df .

type pwd
type pwd in a terminal window

The pwd command is a built-in command of the Bash shell.

type elif
type elif in a terminal window

The elif command is a Bash shell reserved word.

Using Multiple Commands
You can give type multiple commands to identify at once.

type date top ls
type date top ls in a terminal window

The -t Option
None of the options that type will accept have names. So we can get our book of names out and christen them ourselves. If you think of the -t option as standing for “terse,” you won’t be far wrong. It reduces the responses from type to single word answers.

type -t date
type -t pwd
type -t lowdown
demonstration of type -t option in a terminal window

The -a Option
Let’s call this one the “all” option. It lists all of the locations that the command is located in. Note that this option will not work if you also use the -p option.

For example, if you have an alias with the same name as the underlying command, you can get information on the alias and the command.

type -a ls
demonstration of the type -a option in a terminal window

The -f Option
The -f option forces type to not search for user or system defined functions. Think of this option as “function search off.” Note that if the command is a function, type will report that the command can’t be found.

type -f top
type -f lowdown
demonstration of the type -f option in a terminal window

The -P Option
If you use the -P option, type will only search the directories in $PATH. So we can call this option “path.” Note that this option uses an uppercase “P.”

type -P date chmod adduser
type -P date chmod adduser in a terminal window

The -p Option
If you use the -p option, type will only respond if the command is a hard disk file. Note that this option uses a lowercase “p.”

type -p mount
type -p ls
type -p -a ls
demonstration of the type -p option in a terminal widow

type does not give any response for ls because ls an alias, and not a disk file.

But if we include the -a option so that type looks for all instances of the ls command, it lists the underlying disk file that the ls alias makes use of.

Summary
That was nice and simple, but illuminating all the same.

We tend to think of anything we type at in a terminal window as a “command,” and we leave it at that. But actually, commands are implemented in a variety of ways in the Linux system. And type lets you find out which one it is.

0 Shares 0 Like •

Topic image 1

(» Go Up)

You must Sign in or Sign Up to post content

For you to post content on this website you have to log in or register, it only take few minute to create account

Go Up

Recommended for you

How To Claim Unclaimed Financial Assets (beneficiary Claim) In Kenya How To Apply For A Fast Instant Loan From Afrikaloan How To Make Slides Vertical In Powerpoint How To Use The Linux Cat And Tac Commands

Currently: 1 guest(s) reading this article

Sections: Environment, Diaspora, Huduma Centre, Pets, Health, Technology Market, Education, Computers, Phones, Programing, Emojipedia, Forum Games, Literature, Celebrities, Fashion, Burundi Forum, Ugandan Forum, South Sudan Forum, Somalia Forum, Tanzania Forum,

About Us | Terms & Conditions | Privacy Policy | FAQ's | Disclaimer | Copyright | Contact Us | Advertise With Us | Download K247 APP | Marketplace | Moderator Policy | We Are Hiring | Kenya Radio and TV Stations Listen and Watch Live | Letter From the C.E.O | Kenya Radio Stations Live | Kenya TV Stations Live | Kenya - Newspapers and News Sites and popular blog | Forum Rules | Featured LinksFollow Us on TwitterLike Us on Facebook

Kenyans247 - Copyright © 2019 - 2020 Sande Kennedy. All rights reserved. See How To Advertise.
Disclaimer: Every Kenyans247 member is solely responsible for anything that he/she posts or uploads on Kenyans247.