43 Basic Commands in Linux Ubuntu For Beginner with Examples

43 Basic Commands in Linux Ubuntu For Beginner with Examples
43 Basic Commands in Linux Ubuntu For Beginner with Examples

43 Basic Commands in Linux Ubuntu For Beginner with Examples - Basic Linux commands (command line) are the same as when we type commands in DOS, the command line or command line in Linux is also typed at the prompt and ends by pressing the Enter key on the keyboard to execute the command.

The command line is a more efficient way of doing things. Therefore, Linux users still rely on this method to work. It's also a good idea for beginners to know and at least have used this command line because someday knowledge of these commands can be very necessary.

Basic Commands in Linux
Basic Commands in Linux

43 Basic Linux Commands Ubuntu You Should Know

The following will explain some of the basic commands that may be often used, especially by beginners. Caution: knowledge of other commands will quickly increase as you progress to master this Linux operating system.

The explanation of each command will be shortened and to find out in more detail the functions of a command, you can see the manual, for example by typing the man command:

1. Man

man is a command to display the manual of a command. The way to use it is to type man followed by the command we want to know the user manual for.

Example:

$ man ls

The above command is used to show how to use the ls command in full.

Basic Linux Commands

As your guide, here is a list of commands in alphabetical order. In fact, you can just double-press the tab to see all the possible commands that can be used. For example, if you want to know what commands start with the letter a, then you can simply type a and then press tab twice!

2. &

The & command is used to run commands in the background (background)

Example:

$ wget http://id.wikibooks.org &

The & command is used behind other commands to run it in the background. What is running in the background? The path in the background means that we allow the system to run commands on its own without our participation, and free the shell/command prompt so that it can be used to run other commands.

3. adduser

The add user command is use to ADD new user.

Usually only done by root to add a new user or account. After this command can be continued with the passwd command, which is the command to create a password for the user. Example:

# adduser udin
# passwd udin

Note that for all commands that require root access, here I write using the # sign, to make it easier for you to distinguish them from commands that do not need root access.

If you run the adduser command, you will be asked to enter the password for the user you created. Enter the password for the new user twice with the same word.

4. alias

Used to give another name of a command. For example, if you want the ls command to be executed by typing the dir command, then create an alias as follows:

$ alias dir=ls

If you like a colorful look, try experimenting with the following commands:

$ alias dir=ls -ar -color:always

To see what commands have other names at that time, just type the alias (no arguments). See also unalias command.

5. bg

To force a suspended process to run in the background. For example, you are running a command in the foreground (without ending the & command) and one day you need the shell, then you can pause the command with Ctrl-Z then type the command bg to run it in the background. This way you have freed the shell but keep the old commands running in the background.

6. cat

Showing the content from a file on a screen. Example:

$ cat /name/a/file

7. cd

Change Directory or to change directories and I don't think you'll have any trouble using this command because it's similar to the cd command in DOS.

8. chgrp

This command is used to change the ownership of a group of files or directories. For example, to give permission to a group or groups to be able to access a file. The syntax for writing is as follows:

# chgrp <new group> <file>

9. chmod

Used to increase and decrease user permissions to access files or directories. You can use a numeric coding system or a letter coding system. Three types of permissions can be changed, namely:

  1. r for read,
  2. w for writing, and
  3. x to execute.

By using letter coding, you can change the permissions above for each u (user), g (group), o (other), and a (all) by simply adding a plus sign (+) to add permission and a minus sign (-) to revoke permission.

For example, to give permission to read and execute the file try1 to the owner and group, the command is:

$ chmod ug+rx try1

To revoke these permits:

$ chmod ug-rx try1

By using a numeric coding system, permissions for user, group, and other are determined using a combination of numbers, 4, 2, and 1 where 4 (read), 2 (write), and 1 (execute).

For example, to give permission to read(4), write(2), and execute(1) a trial file to the owner, the command is:

$ chmod 700 try2

Another example, is to give permission to read(4) and write(2) the file try3 to the user, and read(4) only to the group and others, the command is:

$ chmod 644 try3

Caution: If you are hosting on a Linux-based server, this command is very important for the security of your data. I recommend all directories that you don't need to write in chmod 100 (if Apache is running as the current user (you)) or in chmod 501 if Apache is running as www-data or nobody (another user).

10. chown

Changing the user ID (owner) of a file or directory

$ chown <user id> <file>

11. cp

To copy files or copy. For example to copy file1 to file2:

$ cp <file1> <file2>

12. fg

Returns a suspended process to run again in the foreground.

13. find

To find the location of the file. This command will search for files according to the criteria you specify. The syntax is that the command itself is followed by the name of the directory where the search starts, then the file name (can use wildcards, metacharacters), and finally determines how the search results will be displayed. For example, it will search for all files ending in .doc in the current directory and display the results on the screen:

$ find . -name *.doc -print

Example results:

./public/docs/account.doc
./public/docs/balance.doc
./public/docs/statistics/prospect.doc
./public/docs/statistics/presconf.doc

14. grep

Global regular expression parse or grep is a command to search for files containing text with the criteria you have specified.

Command Format:

$ grep <text> <file>

For example, it will look for files containing marginal text in the current directory:

$ grep marginal <file>

different.doc: Note: the word marginal is widely used in economics prob.rtf: by the marginal yield function and the marginal cost function if the prob.rtf function: if marginal cost and marginal return are known then total cost.

15. gzip

this is a GNU version of zip compression software, its function is to compress a file. The syntax is very simple:

$ gzip <filename>

However you can provide certain parameters if you need better file compression, please see the manual page. See also the tar file, unzip, and zip.

16. stop

This command can only be run by the superuser or you must be logged in as root. This command is to tell the kernel to turn off the system or shut it down.

17. hostname

To display the system host or domain name and can also be used to set the system host name.

Usage example:

$ hostname

localhost. localdomain

18. kill

This command will send a signal to a process that we specify. The goal is to stop the process. Writing Format:

$ kill <signal> <pid>

PID is the number of the process to be terminated. Don't know which process PID to kill? Try experimenting with the command:

$ ps aux | grep <myusername> 

19. less

Its function is like the more command.

20. login

To enter the system by entering the login ID or it can also be used to switch from one user to another.

21. Logout

To exit the system.

22. ls

Displays the contents of a directory like the dir command in DOS. You can use some of the options provided to adjust how it looks on the screen. If you run this command without the option it will display all nonhidden files (files without a dot prefix) alphabetically and broadly fill the screen fields. Option -la means displaying all files / all including hidden files (files with a dot prefix) in long format.

23. man

To display a manual page or text that explains in detail how to use a command. This command is very useful if at any time you forget or do not know the function and how to use a command.

$ man <command>

24. message

This command is used by the user to give permission for other users to display messages on the terminal screen. For example, if your message is in the y position, other users can display messages on your screen by writing or talking.

# mesg y or mesg n

Use messages if you don't want to be bothered by the display of messages from other users.

25. mkdir

Create a new directory, similar to the md command in DOS.

26. mount

This command will mount the filesystem to a specified directory or mount point. Only the superuser can run this command. To see what filesystems are and their current mount points, type the mount command. You can learn about this command in the chapter on filesystems.

$ mount
/dev/hda3 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hda1 on /dos type vfat (rw)
/dev/hda4 on /usr type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0622)

27. mv

To move files from one location to another. If the second argument is a directory then mv will move files to that directory. If both arguments are files then the name of the first file will overwrite the second file. An error will occur if you enter more than two arguments unless the last argument is a directory.

28. passwd

Used to change passwords. You will always be asked to enter your old password and then you will be asked to enter a new password twice. Password must be at least six characters long and contain at least one character.

29. pwd

Print a working directory, or display the name of the directory where you are currently located.

30. rm

To delete files by default rm doesn't delete directories. Use this command with caution, especially with the -r option which can recursively delete entire files.

Again: Be careful with this command!

31. rmdir

To delete an empty directory.

32. shutdown

This instruction is to shut down the system, just like halt instruction. On some systems, you can stop the computer with the command shutdown -h now and restart the system with the command shutdown -r now or with the key combination Ctr-Alt-Del.

33. su

To log in as another user temporarily. If the user ID is not included then the computer assumes you want to temporarily log in as super user or root. If you are not root and the other user has a password then you must enter the password correctly. But if you are root then you can login as another user without needing to know that user's password.

34. tail

Displays the last 10 lines of a file. The default row to display is 10 but you can specify how many rows you want to display:

$ tail <line count> <file file ….>

35. talk

To hold a conversation via the terminal. Input from your terminal will be copied into another user's terminal, and vice versa.

36. tar

Stores and extracts files from media such as tape drives or hard disks. The archive files are often referred to as tar files. The syntax is as follows:

$ tar <action> <option> <file or directory>

Example:

$ tar -czvffilename.tar.gz /name/directory/*


The above command is used to enter all the contents of the directory, then compress with tar format, and then zip with gzip, resulting in a file named filename.tar.gz

$ tar -xzvffilename.tar.gz

The above command to extract the filenameFile.tar.gz

37. umount

It is the opposite of the mount command, which is to unmount a filesystem from its mount point. After this command is executed the directory that is the mount-point can no longer be used.

# umount <filesystem>

38. unalias

The opposite of the alias command, this command will cancel an alias. So to cancel the alias dir as shown above, use the command:

$ unalias dir

39. unzip

Used to extract or unzip compressed files. The syntax is simple and will extract the files you specify:

$ unzip <filename>

See also gzip and unzip commands.

40. wall

Send messages and display them in the terminal of each user who is currently logged in. This command is useful for the superuser or root to give a warning to all users, for example notification that the server will be shutting down soon.

# wall Dear, everyone….. immediately save your work, I will shut down the server in 10 minutes.

41. who

To display who is currently logged in. This command will display information about the login name, terminal type, login time, and remote hostname for each user who is currently logged in. For example:

$ who

root ttyp0 May 22 11:44

Flory ttyp2 May 22 11:59

pooh ttyp3 May 22 12:08

42. xhost+

This command is used to grant access or remove access(xhost -) to a host or user to an X server.

43. xset

This command is to set several options in the X Window such as the sound of the bell, mouse speed, font, screen saver parameters, and so on. For example, the sound of the bell and the speed of the mouse you can set using this command:

$ xset b <volume> <frequency> <duration in milliseconds>
$ xset m <acceleration> <threshold>

That's all I can share about basic commands in linux, hopefully, it will be useful for you guys.

Thank You

Bangkit Ade Saputra
Bangkit Ade Saputra At the end of the day, my job involves people. we're complicated, we're always changing, we have millions of things going on in our lives, and changing jobs is always a big decision.

Post a Comment for "43 Basic Commands in Linux Ubuntu For Beginner with Examples"