If
you're new to Linux, or just never bothered to explore the command line, you
may not understand why so many Linux enthusiasts are typing commands in the
terminal with enthusiasm. could use a bunch of tools and apps to do it for
them. Here are some of the command line wonders that could make you addicted to
Terminal.
To
use the command line, you must first launch a command tool, also called
"command prompt". How you do this depends on the version of Linux you
are using.
For example, on RedHat, an "Activities" tab, visible at
the top of the screen, allows you to open a list of options and a small window
for entering an order ("cmd" will open the window). On Ubuntu and
other systems, a small Terminal icon is visible on the left side of the screen.
On many systems, pressing "Ctrl + Alt + t" allows you to open a
command window. Finally, by connecting to a Linux system using a tool like
PuTTY, you can access the Terminal directly.
Once
in the command line window, the user is faced with a prompt either in the form
of a simple "$" or something more elaborate like "user @ system:
~ $". In all cases, this means that the system is ready to execute your
orders.
When
we get to this point, we can start writing commands, but first you’ll need to
get a Linux
laptop for programming. Below are some commands to test first. To complete,
you can easily find lists summarizing and explaining the most important Linux
commands.
The main commands:
- PWD Indicates where we are in the file system (initially, this will be your original directory)
- ls Displays files in a directory
- ls -a Displays an even longer list of files (including those that start with a dot)
- ls -al Displays a list of all files with many details (including dates, file size, and permissions)
- who indicates who is online (don't be surprised if it's just you)
- date Recalls today's date (also indicates time)
- ps Displays running processes (can be reduced to shell and "ps" command )
Once
you've gotten used to the Linux command line, there's nothing stopping you from
expanding your explorations.
- cd
/ tmp Moves to another directory (in this case / tmp )
- ls Displays
files there
- cd
Returns to the user's directory (without argument, the cd command always brings
you back to your directory)
- cat
.bashrc Displays the contents of a file (in this case, .bashrc
)
- history
Displays recent order history
- echo
"hello" Poster "hello"
- cal
Displays the calendar for the current month
To
understand even better why advanced Linux users love the command line so much,
you'll probably want to test other features, like redirection and pipes.
Redirection consists of taking the result of order and including it in a
file instead of displaying it on the screen. Pipes are commands that send the
result of one command to another command which will exploit it in one way or
another.
Here are some commands you can try:
- echo "echo hello"> tryme
Create a new file and add "echo
hello" to it
- chmod 700 tryme
Makes the new file executable
- tryme
Execute the new file (should execute the command it contains and display "hello")
- ps aux
Displays all running processes
- ps aux | grep $ USER
Displays all running processes, but limits output to lines containing your
username
- echo $ USER
Displays your username using an environment variable
- whoami
Displays your username with a command
- who | wc -l Counts currently logged in users
Synthesis
Once you get used to the basic commands, you
can explore other commands and try to write scripts. You may realize that Linux
is much more powerful and more enjoyable to use than you would imagine.
0 comments:
We Cherish Your Comments Most, Kindly Drop your comments below. Don't forget to click "Notify Me" to know if we have responded to your comments, Thank You.