If you are a Windows user who wants to learn Linux, Ubuntu is a good choice as it is one of the best Linux distro for beginners. Your initial experience on Ubuntu won’t be very strange. But, if you want to feel the true power of Linux, you’ll have to learn about how to make use of its command line interface. Initially, you will have some difficulties mastering lots of commands. As much as using the commands won’t turn you into a genius, it will help you execute some basic and core actions. To help you have a smooth start, here are the 20 basic Ubuntu commands for beginners.
20 Basic Ubuntu commands
Note: Each command has its own additional parameters to extend its functionality but in this article, we won’t go into that much detail. Consider it to be a basic introduction to the basic Ubuntu commands.
1. mkdir (Make Directory)
One of the common actions that you may want to take is to create a new folder or even go a step further to create a subfolder. To perform these functions, you will have to use the mkdir command and type the name of the folder after it.
Example:
root@server:/# mkdir test
This command will create test directory at the root directory of your server.
2. ls (List)
ls command stands for list. You will use it whenever you want to see everything that is in your directory. It will display all the files and folders that exist in the current directory that you have opened. To use it, just type the directory name then follow it up with the ls.
Example:
root@server:~# ls
This command will list all the files and folders that are in the server’s root directory
sys/ test/ tmp/ usr/ var/
3. cd (Change Directory)
cd is a command for changing a directory in the terminal. It is one of the basic Ubuntu commands that you cannot avoid, no matter what. To use it, you simply need to type the name of the folder that you want to move to.
Example:
root@server:~# cd /test
now you’re inside test directory
root@server:/test#
Basic commands to remember:
root@server:~# cd /
this will open the root directory.root@server:~# cd ..
open one level up directory.root@server:~# cd -
will open the previous directory
4. cp (Copy)
This is the most obvious command, whether you are a newbie or not. It stands for copy-and-paste. It will come handy when you want to organize your files on the computer. To use it, you need to know the file name and the target destination where you will paste it. If the file that you want to copy and paste requires permission from the root, then you will have to use the des command.
Example:
root@server:/test# cp t1/* t2
This command will copy all the files from t1 folder into folder t2.
Also, Read: Important Advanced Linux Commands for Programmers
5. sudo (SuperUserDo)
This command stands for SuperUserDo. It is also a basic and an essential command for the Ubuntu newbies. You will always use it when typing other commands that require to gain permission from the root (if you are not a root user). You simply need to place this command before the command that you want to execute with root permission.
Example:
vicky@server:~$ sudo service apache2 restart
This command will let you restart the web server with root permission. However, you’ll have to enter your password for once.
6. rm (Remove)
The rm command is used for removing files and directories from their current location. You should use -f if the file requires permission from the root and -r if you want to perform a recursive removal of the folder.
Example:
root@server:/test# rm -rf t2
This command will delete the t2 directory and all its content from the test directory.
7. find (find)
Sometimes you may need to use a file but you can’t find its exact location or remember its path, use the find command. It will help you to find that file with ease. You only need to type this command then add some keywords about the file.
Example:
root@server:/test# find t1
t1
t1/xd.p
As you can see it found everything related to t2 in the test directory
8. poweroff (Poweroff computer)
This command lets you switch the computer using the Ubuntu terminal. It is an ideal option for turning a computer off without using the mechanical method. if you are not a root user, you should type sudo command before typing poweroff.
Example:
root@server:/test# poweroff
and the system will shut down
9. Cat (concatenate)
One of the common things that you may intend to do is to inspect texts and codes in your script. The cat command is used for viewing those texts and even codes that are in a particular file that you have opened.
Example:
root@server:/test/t1# cat hello.txt
Hi, This is for testing only
The above command is showing the text that was inside the hello.txt file.
10. Pwd
When using Ubuntu, it is always prudent to the current directory that you are working on. This will help you to know where you will go next. pwd is the best command for doing this job. It will print your current directory.
Example:
root@server:/test/t1# pwd
/test/t1
the above command is showing the directory in which you are right now.
11. mv (Move/rename)
You will need this command whenever you want to move your file to a different location or give it a different name. When it comes to renaming, you need to type both the old and the new name. Remember to start with the des command for files that require permission from the root.
Example:
root@server:/test# mv t1/* t2
root@server:/test# mv t2 test2
root@server:/test# ls
t1 test2
In the above example first command will move all the files from t1 to t2 and the next command will change the name of t2 folder to test2
12. rmdir (Remove directory)
Apart from removing files, you may also need to remove a directory. This is the command for doing this job. If you want to remove a directory named t1, just type “rmdir t1”.
Example:
root@server:/test# ls
t1 test2
root@server:/test# rmdir t1
root@server:/test# ls
test2
The command rmdir t1 successfully deleted the directory t1 from test directory.
13. touch (Create blank file)
The touch command is used for creating blank files in the Ubuntu terminal. It can be compared to the mkdir command for directories. You can use it to create a file in any directory that you want.
Example:
root@server:/test/test2# touch empty.txt
root@server:/test/test2# ls
empty.txt hello.txt
The above command has created an empty text file named empty.txt under test2 directory.
14. apt-get (Download, install, and update software)
You will need this command when you are trying to install a software that you want to run in your Ubuntu PC. Apart from the installation, you will need this tool when upgrading and uninstalling your software. Since most of these actions will require to get permission from the root, you will always have to start by typing the sudo command.
Example:
root@server:/# apt-get install apache2
This command will install apache web server on your ubuntu os. you can also use apt-get command to update the system.
root@server:/# apt-get update
15. free (check free ram)
You can use this command to check the amount of free and used RAM in your computer.
Example:
root@server:/test/test2# free
total used free shared buff/cache available
2097152 598076 1417768 232288 81308 1424127
The above command showing how much ram is being used and available.
16. df (Disk space)
As a normal computer user, it is prudent to check the disk space that is available in your operating system. df is the command for checking disk usage in your Ubuntu. It is usually used along the -h parameter.
Example:
root@server:/test# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/simfs 95G 2.3G 93G 3% /
devtmpfs 1.0G 0 1.0G 0% /dev
tmpfs 1.0G 0 1.0G 0% /dev/shm
tmpfs 1.0G 99M 926M 10% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.0G 0 1.0G 0% /sys/fs/cgroup
none 1.0G 0 1.0G 0% /run/shm
The above command shows which file system is having how much disk space, how much is available and where it is mounted.
17. Chmod (Change Permission)
chmod is an important command that you can use to change file and directory permissions. These permissions include read, write and execute. You need to type chmod, followed by the specific permission then the filename or folder.
Example:
root@server:/test# chmod 755 test2
This command will grant Read + write + execute permission to the User and read + execute permission to the group and everyone else. Learn more about file permissions here.
18. du (Directory usage)
du command displays the size of a directory and all of its subdirectories.
Example:
root@server:/test# du
8 ./test2
12 .
19. service (Run System V init scripts)
Service command is very useful command for running, stopping or restarting System V init scripts that are stored inside/etc/init.d directory.
Example:
root@server:~# service apache2 restart
This command will successfully restart your apache server.
20. <command name> -–help
This command will provide you all the details about the command you are running and the parameters associated with it
Example:
root@server:/test# mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
..
This above commands explain the working of mv command and list all the parameters associated with it.
Conclusion
Mastering all these basic Ubuntu commands may be hectic to a newbie. It is important that you start practising them daily. Once you are able to use these basic commands, you will have a smooth time graduating to the advanced Ubuntu commands.
0 కామెంట్లు:
కామెంట్ను పోస్ట్ చేయండి