DEV Community

Cover image for Using a Linux machine for beginners.
Joseph Igwe
Joseph Igwe

Posted on

Using a Linux machine for beginners.

Linux is an open source operating system, unlike windows, its environment, is constantly being updated by contributors. Developers can easily access the Linux source code for customization. Linux offers a higher degree of security, stability , and require little disk space. It has powerful networking capabilities and gives the user power over the machine. Linux is so popular that Android used on mobile are built on its framework.

In this guide I will show you some of the few basic commands to know to get started.
To begin, you will need to download and install Linux on your workstation. Be reminded that Linux comes in different distributions such as Ubuntu, CentOS, Debian, Fedora, Xubuntu, Arch etc.

1 sudo su - This is the first command that gives you root access over you machine , without it you cannot not run any command on you machine. Depends on the configuration it may require you for password. sudo su

ubuntu02
You will see we do not have permissions to install a web server nginx without doing sudo su.

ubuntu04
2 apt update - It is used to update the package index files in the system which contains information about available packages and their version. apt update

ubuntu05
3 mkdir - The function creates a new empty directory /folder in windows machine, whose name is defined by path. You supply the name as an argument. The rmdir is used to remove directories, only when there is no file inside it. To remove dir classrep,

ubuntu06

ubuntu09

4 list: This is a very powerful and commonly used command. ls, without any options list files and directories in plain format without displaying much information, like file types, permissions, modified date and time etc. Some of these options includes:

4.1 list in reverse order : ls -r
4.2 To list permission of files and other attributes such as folder name, size and modified date and time. ls -l
4.3 Using this syntax further modifies your listing to become human readable.it becomes easy to understand. ls -lh,To learn more about more,click
ubuntu08

5 Print working directory : This command displays the path of the working directory starting from the root. Its a shell in-built command.pwd
Pwd [options]
5.1 "L": Path resolves symbolic link and prints the path of the target
5.2 "P": Displays the actual path without resolving the symbolic link.

6 Creating text files(touch): When we want to create text files , use the command touch file_name'. It is used to creates a file without any content. to create a file with a content, use 'cat command'.
The touch command can also create multiple files in one command

touch file1.txt file2.txt file3.txt
Enter fullscreen mode Exit fullscreen mode

Note
use one space as the separator.

ubuntu10
7 concatenate (cat) - This is a very useful command in Linux, it helps us view, create and concatenate files. Concatenate is reading data from file and giving their content as output.
Some useful cat commands are below
7.1 View the content of filename1:

cat file_name1
Enter fullscreen mode Exit fullscreen mode

7.2 This is used to view multiple files:

cat file_1 file_2 
Enter fullscreen mode Exit fullscreen mode

7.3View content of a file preceding by number line :

cat -n file_1
Enter fullscreen mode Exit fullscreen mode

7.4 This command creates a new file :

 cat > file_1 
Enter fullscreen mode Exit fullscreen mode

ubuntu11
In the next graphic we can see how we view content of a file, click the link to learn more

ubuntu12

8 copy (cp) - This is the copy command in Linux, used to copy files and directories from one location to another.
cp [source] [destination],to do this navigate to the folder where the file to be copied is located , and specify its filename and the path where it is to be stored.

ubuntu13

ubuntu14
8.1 copying multiple files - We do this using the command

cp text1.txt text2.txt text3.txt /home/user/destinationfolder/

Enter fullscreen mode Exit fullscreen mode

ubuntu15
The above diagram shows us when we are copying the files ,file1txt,file2.txt,file3.txt from their source folder "Businessclass" to destination folder "learn".

9 Change directory cd - This command changes the current working directory to another one specified cd
9.1 changing to previous: Adding a dash(-) returns you to your previous directory. cd -

9.2 Home directory: The absence of the current directory path shows you are at the home directory. Use the command cd to go to home, also when you use the command cd ~ it takes you to the home directory.

ubuntu16.1
As you see above there is no path. Using cd ~ does the same thing as above.

ubuntu16.2
We can use the cd command to do a lot in Linux workspace
10** exit** : It takes a parameter[N], and return the status as [N], if it is not provided, it returns back to its previous status.
ubuntu17.1

File Editors in Linux
We have many text editors in Linux like vi, vim, GNU Nano, gEdit and more. In this exercise we will focus on using vi.

To create and edit a file using vi

On your machine follow this step
1 type vi filename , It opens a file with the name specified or creates a new file .

ubuntu18
2 Press i on your keyboard to start editing ,

ubuntu19
3 After editing Press ESC to exit insert mode.
Then use “:wq!” to save and exit editor or “:q!” to exit editor without saving.
Using vi to create a text file and saved in a folder Hagital
1 Create the directory "Hagital" with mkdir command.

ubuntu18

Top comments (0)