0% found this document useful (0 votes)
36 views3 pages

Linux Command Basics for Beginners

Uploaded by

shashinarmala29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Linux Command Basics for Beginners

Uploaded by

shashinarmala29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Welcome to Informational Commands.

After watching this video, you will be able to:


Find user and operating system information.
View system disk usage.
Monitor running processes and their resource usage.
Print strings, variables, and dates
Display manuals for commands
You can use informational commands in your terminal
to display user information about your system.
User info commands are useful when you need to verify the identity of the current
user
or determine which user account is running a particular command or process.
For example, the command “whoami” displays the current user’s username.
The “whoami” command takes no arguments and has no options.
Here you see a usage example for someone logged in as user “John Doe.”
Similarly, the “id” command returns the user or group ID,
which is a number assigned to each user or group in the Linux system.
In this example, using “id” with the “minus u” option returns
the numerical ID of the user.
If you would like the name corresponding to the numerical user ID,
add the “minus n” option.
The “uname” command, which stands for “Unix name”,
returns OS information such as the kernel name and version number.
This can be used to identify the type of system you are working on
or diagnose system-related issues.
Entering the uname command returns the name of the operating system,
which in this case is Darwin.
Including the “minus s” and “minus r” options returns
both the OS name and its version.
You can also view more detailed version information
using the “minus v” option.
You can use the “df”, or “disk free” command to display your system’s disk usage.
It can be useful in situations where you need to monitor disk usage
or check the available space on a particular file system.
For example, entering “df minus h tilde”, displays the following table,
which is specific to your home directory, represented by the tilde symbol.
In this table, you can see all the disks mounted on your home directory.
In Linux, you can “mount” a disk onto a directory, which means that the file system
of that disk
becomes accessible through that directory.
The table also displays the percentage of storage used on each disk.
The “minus h” option makes the output “human readable,
expressing disk space in units
like Gigabytes and Terabytes instead of Bytes.
To view disk usage on all filesystems,
you can simply type “df minus h” without specifying a directory.
The output includes the size, capacity used, and available space for each
filesystem.
To see the currently running processes on your system,
you can use the “ps”, or “process status” command.
This is helpful when you need to monitor or manage processes.
Using “ps” with the “minus e” option will list all processes
running on the system, regardless of which user started them.
The “ps” command displays information such as the name of each running process, the
process ID,
and the time in minutes and seconds that each process has been running.
The “top”, or “table of processes” command acts as a task manager
and will show a table running processes and their resource usage.
This command comes in handy when you need to monitor system performance
or identify resource-heavy processes.
Here we show a usage example with the “minus n” option
and the number “3” to display the top three running tasks:
Chrome, top, and Spotify.
By default, tasks are sorted by CPU usage.
This is a simplified output of the “top” command for this video,
but “top” provides many other details such as
memory usage and the executable file location.
Although simple, the "echo" command in Linux is a powerful tool
to display text or variables on the terminal or in a shell script.
Entering just “echo” is similar to telling the terminal to print nothing,
and it will return a newline.
If you would like to echo a single word such as “hello”,
you can simply type “echo hello”, and the terminal will return the word.
Strictly speaking, you don't need to add quotes around a string
with spaces for echo to work as expected,
but it's considered best practice to include quotes.
Using echo with a quoted string returns the quoted contents, “Learning Linux is
fun!"
Additionally, you can view the value of a variable,
such as our system’s “PATH” variable,
by typing a dollar sign followed by the variable name.
This can be helpful when troubleshooting or scripting.
Here you can see each path of your system’s PATH variable, delimited by colons.
Another helpful command is “date,” which displays the current system date and time.
Entering “date” returns the default date format:
the day of the week, the day, month, year, time, and the time zone.
You can also extract certain parts of the date to print, like in this example.
To format the output, encapsulate within quotes a combination of text
and control characters preceded by a “plus” sign.
Format controls are indicated with the % symbol.
In this case, “percent j” and “percent Y” output
the numerical day of the year and the year itself, respectively.
This command prints “97”, for the 97thth day of the year,
the words “day of”, and the year, “2023”.
Notice how “percent Y” is replaced by the year 2023.
Finally, here is another example to show how you
can further combine format controls with text to print unique strings.
By bringing together controls like “percent A”, “percent j,” and “percent Y” with
text,
you can print a line that tells you the day of the week, the day, and the year.
This video has only covered the basics of these commands.
If you want to learn more about how to use a command,
you can use the “man”, or “manual,” command.
All default Linux commands come with a manual that you can display using “man.”
For example, entering “man ID” will display the manual for the “ID” command.
The manual will provide a basic summary of what the command does, such as “return
user identity”.
Also listed are the options for the “ID” command, such as “minus a.”
Square brackets indicate optional parameters, such as “user,” which allows you to
specify a username.
The “man” command also provides a more detailed description of the command,
which explains it in greater detail.
The “man” command even has its own “man” page—you
can use it to learn more about the manual command and its uses.
In this video, you learned how to:
Get user information with the "whoami" and "id" commands,
Get operating system information using the “uname” command,
Check system disk usage using the "df" command,
Monitor processes and resource usage with “ps" and "top",
Print string or variable value using "echo",
Print and extract information about the date with the “date" command,
And read the manual for any command using “man”.

You might also like