Basic Linux Commands For Beginners
First of all, I want you to know something about linux. I assume you know already about that. Then also, Linux is a family of open-source Unix-like operating systems based on the Linux kernel. Some people get confused about linux kernel and linux. Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name "GNU/Linux" to emphasize the importance of GNU software.
So we can start now. I
assume you have linux in your computer. At first we will see about creating
users and changing passwords. And if you are stuck with a command you can get
help from that command like real life help line. Such as:
If you want to check
which user you are running ,then
$ whoami
Suppose you are stuck now, So all you have to write........
$whoami -h or whoami –help
Or........
$man whoami
Now, to create a user ......
$useradd username or sudo useradd username
sudo is used if you are logged in as a user and you need root permission to execute a command.
Interesting fun fact,
suppose you are logged in as a user and you want to get to root. So, all you have to do is .....
$sudo su
Now, we have to give a password to the user we created.
$passwd username or sudo passwd username
You know the deal about sudo now . So I will ignore it for some time.
If you want to get one
user from another,
$su username
You also can delete the user you created.
$sudo userdel username
There are so much to learn about useradd. We will talk about it in another post. However, new user created but we don’t know about directory.
We all use windows for
our daily necessary. There we use folders. Directory is like folders in a way.
A directory is used for organizing your files in a hierarchical order.
To check where you are,
$pwd
I want to go in another directory.
$cd Desktop
$cd /etc
$cd /usr/share
I want to go back one directory back.
$cd ..
Say, you want to go way back.
$cd ../../../
I want to go to home directory.
$cd
Now we want to list the directories. There is a simple command for that.
$ls
If you want to see file permissions and other information,
$ls -la
Now we want to create some files and folders. In windows, it’s super easy. But after learning these linux commands you will change your opinion. Let’s go.
If you want to create a
file,
$touch infosec
There are some other ways to create files. We will get into that later. You know about echo command though. echo command is like a printing machine. If you write something after echo, it will print that.
$echo “I am a printing machine”
Let’s learn about something else with echo.
$echo welcome > myfile
Here, what happens is that you write welcome into the file named myfile. This is another way of creating file.
If you want to create a folder........
$mkdir info
Suppose you don’t like the infosec file. What do we do with those that we dislike? We delete them. So, to delete a file,
$rm infosec
You don’t like the info folder either. So let’s delete that.
$rm -r info or rmdir info
Now we want to do what we do best. Let’s copy a file.
$cp oldfile /newdirectory/newfile
If you want to move your file to another directory.
$mv oldfile /newdirectory/newfile
You can use mv command for renaming file.
$mv oldfile newfile1
Enough with file creation and deletion. Let’s find some file. In linux, you can find files with just one command. Neat , eh! Let’s get into the terminal.
First, we will start
with a basic command.
$locate aircrack-ng
Sometimes, you will get too much information with locate. So we have another weapon. To get precise result than locate,
$whereis aircrack-ng
Although whereis also can’t give your desired result sometimes. Don’t worry we have another one.
$which treasurefile
Still you can’t find what you are looking for!!! Let me get the big gun from our arsenal. The Find command.
$find directory options expressions
$find / -type f -name treasurefile
First, we state the directory, then type of document and at the end, name of the file. To be honest, find is a important and necessary command for cyber security career. So you have to learn about find and practice it hard to get it into your head. Find command has massive options. We will talk about it in another post.
Now we will learn about
cat command. The cat command will show the contents of a file.
$cat note.txt
Another important command is grep. It looks for specific values we are looking for. Suppose you are looking for a name in a big file. It will take much more time if you look like general way. Using grep command will save your time.
$cat grepPractice | grep terminated
Oh! That operator you see it’s used if you want to run another command following the first one. The second command works on the results of first command. If you want to run two commands side by side, you have to use && operator.
If you want to measure
file’s size, you can use wc and nl command. wc command counts every word of a
file. nl command counts the lines of a file. Suppose you have a big file and
you want to see only first couple of lines. For that you should head command.
It shows the starting of a file. To see the end, you might use tail command.
$wc file
$nl file
$head -1 file
$tail -1 file
I know you see -1 up there. The number represents how many lines it will show from top. You can give -100 there if you have that big file. Same goes for tail.
These are some basic
commands that we have seen today. This is just for giving you a simple idea of a
linux commands. Now you have to learn more to be an expert in linux CLI(Command Line Interface).
To be honest, I feel like a hacker when I work on the terminal.
If you want to learn
more, you can read the book named Linux Basic For Hackers. And I recommend you
something that you can practice. Tryhackme is good place for practicing cyber
security skills. They have a bunch of rooms about linux. Finish them for
getting better at linux commands. It’s a special skillset to have in your
pocket. Here are some rooms about linux in tryhackme. Test yourself now. Best of
luck for your upcoming future.
TryHackMe
| Linux Fundamentals Part 1
Writeup: Tryhackme - Linux Fundamentals Part 1 WriteUp
TryHackMe
| Linux Fundamentals Part 2
TryHackMe
| Linux Fundamentals Part 3
No comments