Dear friends, the big day has finally arrived. If you are reading basic Linux commands for beginners I suppose that you have already read our previous article, Linux tutorial for beginners, and if not yet I suggest you have a look at it in order to be on the same level otherwise continue reading. You will get the chance to write your first command in the console! Okay, not too stressed?
I assure you, we will start with simple things to become familiar with the console. We’ll really see the ABC, the basic survival guide of kits.
Basic Linux Commands for beginners
Then, let us see what this article is going to cover.
- First Commands on Linux command Line
- Understand Super User on Linux
- Commands & parameters
- File operation Commands
- Directory Commands
- account manager commands
- Permission Commands
- System Command
- Networking commands
What is the Linux shell?
Before we continue let me remind you what a Linux shell is. A Linux shell is a command-line interpreter or shell that provides a traditional user interface for the Linux operating system and for Linux-like systems. The shell understands plenty of shell commands and their options which change their action. The typical syntax of shell command looks like this: command –option argument (parameter).
In our previous article, we saw the history of Linux and other things, we also discussed Linux distributions and I’m very sure you have chosen what you found the best for you. Also, if you weren’t able to choose a distribution of your choice, you might find this article interesting for you, the top 6 best Linux operating systems for hacking and penetration testing.
First basics Linux commands for Beginners.
Then, the time of testing your first command is now; open your Linux command line to write your first command. Also, know that for my side I use Kali Linux and all command you will find on this article was tested on kali.
This is a command prompt. It is a message that prompts you to enter a command by giving you at the same time a lot of information. This command prompt is displayed before each command you type.
Now let us explain something about what you are seeing in command line.
Anonymous: The first element is your nickname. This is the user name under which you are logged. Indeed, know that you can create multiple user accounts on Linux
@: This symbol indicates nothing special. It’s the symbol “at’”.
DESKTOP-4312L0R: That’s the name of the computer on which you are working. In my case it’s called DESKTOP-4312L0R, but I could give any name during OS installation.
~: That’s the folder where you currently are. You can also navigate folder to folder in the console and it’s very useful that you always be reminded where you are before each command.
$: Also, that symbol is very important, because it shows you your authority level. This symbol means you are currently a normal user with limited rights. If you are curious and you want to know why limited rights read the previous post about Linux tutorial for beginners-Linux guide in 2021.
Tasksel: This is a command to install some additional Linux components.
Understand Super User in Linux
In this part, we are going to see who is a root. Then, let us see what really Superuser means. know that in some distribution of Linux you are not allowed to log in as a superuser because of the security matters, the reason why by default Linux let you log in as a normal user.
Then, once you have log in, you can now run commands as a root but first, you have to run the command sudo su, and then it will ask you to confirm with the password. When typing a password it won’t show if you are typing, but if you write the right password confirm with the button enter.
$: This symbol means you are currently using a user “normal” account with limited rights (he cannot change the most important system files).
Also, if the symbol is “#” that mean you are in super user mode. That is to say, you are connected under the pseudonym “root”.The root is the master who has the right to do everything on the computer he can even run harmful commands.
parameters & Basic Linux Commands .
Command: It is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. In Linux when you are typing command you are ordering the terminal to execute task for you.
Example: mkdir genius – here you ask the computer to create a folder named genius.
Parameters: Parameters are options that are written after the command. The command and parameters are separated by a space. The parameters themselves can contain spaces, letters, numbers … a bit of everything, really. There is no real rule on how the settings, but fortunately programmers have adopted a sort of “agreement” so that we can recognize the different types of parameters.
Also, know that there are two differents of parameters.
- Short parameters: The most common parameters are constituted by a single letter preceded by a dash. For instance: -d, –l, –a.
If you have to give several parameters, you can do it like this: -d, –a, –U, –h. Also, you have to know that each parameter has different meanings.
- Long parameters: The parameters consist of several letters are preceded by two dashes like this: –all, –version, –help
Commands and parameters Examples
Then, let’s have a further look about the commands and their parameters.
- Su –l: switch user, (su: login as the root super user and –l: is a parameter meaning “login”).
- Ls –a: list all contents, (ls: list content and –a: is a parameter meaning “all contents”.
- rm -ri genius: (rm: removes a file or a directory, ri: is a parameter meaning remove a non-empty directory and its contents, and genius is the name of the directory to remove.)
- usermod -l anonymous genius: (usermod: modify an existing user account, -l: is a parameter meaning “login name change”, anonymous: is the old user name, and genius: is the new user name we want to set).
- whoami: shows the current user name, the output is “Anonymous”
File operation Basic Linux Commands
Then, let discuss how we can manage files on CL. Managing files on the Linux command line is not as complicate as beginners may think.
- cp myfile/genius: the command cp: copy, myfile: is the name of file you want to copy, and genius: is the directory where you want to copy myfile.
- mv myfile/genius: mv: command to move a file, myfile: is the name of file you want to move, and genius: is the directory where you want to move myfile.
- rm genius: rm: command to remove a file or directory, and genius: name of the file you want to remove. Also, you can use –ri as parameters if you want to remove a directory with all its contents.
- wc myfile.txt: This is a command to count words on a given file. wc: show word count, and myfile.txt: Name and extension of the file.
- lpr myfile.txt: the command of sending the myfile.txt to the printer. lpq command help to display the print queue
- diff myfile1.txt myfile2.txt: the command diff: show the differences between two files, myfile1.txt: is the file to compare to myfile2.txt.
- cmp file1.text file2.txt: this is the command to compare two files byte by byte.
- Md5sum myfile.txt: this command will create an md5 checksum number. Output: f7tkgu5orj1fjt8kelc2os95nd57jf8r myfile2.txt.
- grep hacking myfile.txt: the command grep: show all lines that contain “hacking” string. It shows a specified string.
- egrep excellent myfile.txt: It seems similar with grep but the difference is that this command show the unique lines in the file.
- look ab: this command show words matching a given prefix. The output will be: aba,abb,abc,abd…
you may also like to know the difference between termux from Linux
Directory basic Linux commands for beginners
Also, you may find that managing directories is simple as a beginner. Then, in this part we won’t see many commands but you can do research to get more.
- mkdir genius: this command hell to create a new directory with the name genius.
- rmdir genius: help to remove an empty directory. That mean you ask to the CL to remove the directory genius.
- zip myfile.txt: this file help to compress a file to zipe format.
- unzip myfile.zip: Also, this command help to unzip a file from zip format.
Account manager Commands
Let us see how we can manage users accounts using Command line.
- useradd username: add a new user account.
- usermod -l oldname newname: Also, help to change the username.
- userdel username: this command help to delete a user account.
- passwd username: set a user account password
permission basic Linux commands
- chmod 752 myfile.txt: the command chmod: change the mode of access permission for myfile1.txt, 7: set user permission with write, read, execute, 5: set group permission with read, execute, 2: set others permission with write only.
- chgrp groupname myfile.txt: chgrp: change group membership of a file. Also, groupname is the name of a given group if you created a group.
- chown username myfile2.txt: the command chown: change ownership of myfile2.txt.
System basic Linux commands
- job: this command displays the status of all jobs.
- fg: Also, this command run a suspended job in foreground.
- bg: run a suspended job in background
- kill %4: this command kill a job by number or a process by pid
- at 9:30 pm: Also, this command help to schedule a job run at a specified time. You can also display the scheduled jobs wit at command, and if you want remove a schedule use atrm command.
- uptime: It also shows the system uptime.
- top: Also, help to view the top active or specified process.
- tar -xf archive.tar: it also help to extract an archived tar file.
- tar -cf archive.tar: create an archived tar file
- date: also, help to display the date and time.
- cal: it also help to display a calendar of month.
- df: This command help to show disk usage of file system
- host tgeniusclub.com: display remote hostname and IP
- ifconfig: Also, display local network configuration
- ping -c3 tgeniusclub.com: it also send packets to test if remote is reacheable
- ssh: securely connect to a remote computer ftp: files transfer by “File Transfer Protocol”
- mesg: it also enable or disable messaging
- write: write a messages to other users
- open: it help to connect to an ftp server
- mail: Also, send and receive mails locally and globally.
- dhclient: provides a means for configuring one or more network interfaces
- nslookup: query internet name servers interactively for IP information.
Well done, this article was only for basic Linux commands hope now you are able to use your CL. If you want to know more about a command just use command man “name of command””