This short course will be your first step into Linux and we will cover much more then just Linux commands for beginners and Linux fundamentals

Linux for beginners. First meeting

As the readers’ response shows, the interest in solutions based on Linux is very, very high, at the same time, the level of training of administrators in this area leaves much to be desired. Evidence of this is the endlessly repeating simple questions in the comments. In many ways, this is a consequence of the fact that our instructions can be followed “literally” and get a working result. But there is also a downside to the coin, this approach does not provide for the emergence of systemic knowledge, leaving knowledge of the subject at a fragmentary level.
Yes, in addition to practical materials, we always try to publish reviews on a particular technology in general, or make extensive theoretical digressions, so that the reader has the necessary minimum knowledge. However, they all imply that the reader has basic knowledge of the system in which he works.
But what about those who are just taking their first steps? Unfortunately, there is some snobbery in the IT community, they say, what to say about it, everyone knows this anyway, or “google help”, forgetting that each of us was once a beginner and looked at a black screen with mystical horror Linux consoles, absolutely not understanding where he got to and what to do.
As a result, a beginner, faced with the first difficulties, is forced to go to look for knowledge in another place and it is good if such a place can be found quickly. Therefore, we decided to release a small series of materials in which to explain the basics of Linux systems administration at an accessible level, literally explaining “well-known things” on their fingers, experienced users can skip this cycle, or they can read it, at the same time updating their knowledge.
So you’ve decided to become a Linux administrator …
In most cases. There is a need, there is a desire, there is a basic set of knowledge on working with Windows systems – all this will come in handy when working with Linux systems. It is much worse if any component is missing, then, perhaps, it is worth thinking about the wrong choice of profession.
Immediately about what you need to forget once and for all. These are “religious wars” and “religious fanaticism.” It is equally bad to deny the capabilities of Linux systems, as it is to extol them, trying to translate everything that is needed and not needed to Linux. Remember – an operating system is a tool, a good specialist takes the most suitable one for each task, a fanatic will hammer in nails with a microscope, because “religion does not allow him to take a hammer”.
Even more, the operating system itself has no value, it is just an environment for starting and executing some services and services. Without software, the system is dead. Let’s take a clone of BeOS – Haiku as an example, well set, well, look – it’s cool … And then what?
So, you decided to become … First of all, be ready to accept the new, in particular the new approach to administration, trying to forget about the established habits for a while. For a long time, the console will be your main tool.

For those accustomed to graphical Windows admin tools, this may seem daunting. But one truth should be firmly grasped – the console is the only full-fledged Linux administration tool and does not mean at all limited capabilities or inferiority of the system. On the contrary, the command line allows you to accomplish many tasks much faster and easier than graphical administration tools.
But there are graphical administration tools, another reader will say, the panels are different, or you can put a graphical shell. It is possible, but not necessary. Why? Take a close look at the diagram below:

Linux, which was created in the image and likeness of UNIX systems, is a full-fledged system and without a graphical shell, moreover, we can start, close or even change the graphical shell without any impact on the system’s performance and even without rebooting it. We finished our Gnome session, launched KDE, and then quit the console. Therefore, all system management tools are designed to be used in command line mode. And all panels and graphical tools are just a superstructure above them.
For a long time, Windows was developed using a fundamentally different technology, the graphical shell was put into the basis of the system and for a long time was even executed at the kernel level (Win 9x family). Therefore, all administration tools were originally graphical, and command line tools supplemented rather than replaced them. Anyone who has dealt with Windows recovery knows that the command line tools there are significantly limited and are intended primarily for system recovery, not for its administration.
This situation began to change with the release of PowerShell and Core versions of Windows Server. Despite the fact that today the graphical shell continues to play a significant role in Windows systems, administrators have gotten their hands on an alternative tool – the PowerShell console, which allows you to fully administer Windows in command line mode. At the same time, PowerShell’s capabilities immediately gained popularity among professionals, as they allow you to perform many tasks faster and easier than graphical tools.
And also the command line mode gives you unlimited opportunities to create your own scripts and scripts that allow you to perform complex sequences of actions in automatic mode or on a schedule.
After that, it seems to us, you will have to look at the Linux console from a completely different side. As for panels and graphical tools, there are significant differences from Windows systems. On Windows, graphical tools are a complete alternative to PowerShell. In Linux, graphical tools are an add-on over the console, in fact using the same tools, but through an additional layer. Therefore, we strongly advise against using all kinds of panels and other graphical tools, at least until you have mastered the console. After that, you can already decide for yourself whether you need a panel or if you can make everything easier and faster through the console.
The fascination with panels at an early stage of acquaintance with the system leads to the fact that the skills of system administration will be replaced by the skills of working with the panel, which is fraught with problems when the panel for any reason will be inaccessible, but it is necessary to work with the system. This can be compared to the fact that a person who has learned to drive a car with a manual transmission will easily switch to an automatic transmission, and a person who initially knows how to drive only an automatic transmission is unlikely to be able to drive a car with mechanics without additional training.
If you haven’t changed your mind about becoming a Linux administrator yet, let’s go ahead and look at the differences in system architecture.
Kernel and drivers
The core of any operating system is the kernel. There are several different kernel architectures, Linux, like the vast majority of UNIX systems, uses a monolithic kernel, Windows, on the contrary, uses the concept of a microkernel, although Windows is not really microkernel architecture, it is generally accepted that Windows uses a hybrid kernel.
A feature of a monolithic kernel is that all hardware drivers are also part of the kernel. Previously, when changing the hardware, the kernel had to be rebuilt; today, monolithic kernels use a modular scheme, i.e. dynamically allow you to load the necessary modules responsible for a particular functionality. Those. having added a new device to the system, we must dynamically load the corresponding kernel module, and if there is no such module, then work with the device will be impossible. As a solution, we can build the module ourselves, but the module will be compiled for the current kernel version and when it is changed, the module will need to be recompiled.
In microkernel and hybrid architectures, drivers, although they can work at the kernel level, are not part of it and do not depend on the kernel version. Therefore, we can easily update the kernel or use the same driver for all versions of systems with a common kernel structure. For example, in Windows, the entire family of modern operating systems, from Windows Vista to Windows 8.1, often uses the same driver.
This does not mean that Linux is worse in this regard, a different architecture provides for different approaches. In practice, this means only one thing – the choice of hardware for servers should be treated more carefully, trying to ensure that all the main devices are supported by the kernel of your distribution. This is especially true for network cards. It will be very unpleasant if after each kernel update you have to run to the server room, connect a monitor and keyboard to the server, and rebuild the kernel module.
In fact, there is no such thing as a driver in Linux systems. Hardware is either supported by the kernel or not. The undoubted plus of the monolithic core is that it is self-sufficient. If all the hardware is supported – just set it up and forget it, it’s time to remember the situation when there is no network card driver under Windows and the disk is lost.
File system
We will not touch on specific file systems, there should be no problems here, if the administrator worked with Windows systems, then what is a file system and how FAT differs from NTFS, so he knows the difference between ext3, ext4 and, say, ReiserFS for him it will not be difficult. Let’s talk about the fundamental differences. Unlike Windows, the Linux file system is hierarchical. It starts from the root, which is denoted by a / (slash), and has a tree structure. It does not matter at all that certain parts of the file system may be located on other partitions or even physical disks.
Let’s consider one more scheme.

In Windows, each partition has its own file system and letter that represents it. All paths to files and folders begin with a letter, i.e. from the root of the section. So if we had a DATA folder on the first physical disk, on the second logical partition, then the path to it will accordingly be like D: DATA, if we want to transfer it to the second hard disk, then let it change to E: DATA. In some cases, this is terribly inconvenient, since the path must be changed in all places of its use, and there are even corresponding utilities.
In Linux, the approach is radically different. It’s time to get acquainted with the term mount point , which means the location of the file system where the storage device is connected. For example, we want to move the home directories of users to a separate partition, as in the diagram above, for this we need to mount the second logical partition of the first physical disk sda2 in /home . Then transfer all user data there. For the system and programs, this will happen absolutely transparently, they both used the absolute path, say /home/andrey/data , and will use it. Have you added another disk and want to move the / var directory there ? No problem, stop the services using the directory, mount sdb1 to /var and transfer data, start services.
Everything is a file
Another fundamental principle inherited from UNIX systems. In Linux, everything has a file: devices, disks, sockets, etc., for example, opening /var/run we will see pid-files corresponding to each running service on the system, and in /dev files of each device connected to the system.
What does it do? We will not go into details, but we will analyze a few simple examples. Let’s say you want to create an image of an optical disc. In Windows we need specialized software for this, in Linux everything is simpler, a CD-ROM is a block device, but at the same time it is a file, a file of a block device. Take the appropriate tool and copy the contents of the device file to the ISO image file:
dd if =/dev/cdrom of =/home/andrey/image.iso
Want to replace your hard drive? It couldn’t be easier, copy the contents of one block device file to another block device file:
dd if =/dev/sda of =/dev/sdb
And you don’t need any Partition Magic.
Another situation, some software is strongly looking for the lib-2-0-1.so library, and we have one compatible with it, but a newer one, lib-2-1-5.so, what should I do? Create a symbolic link to lib-2-1-5.so named lib-2-0-1.so and everything should work. Because everything is a file and a symbolic link is also a file type. Now try to slip Windows into lib-2-0-1.lnk instead of lib-2-1-5.dll …
Or we need to save the output of some command. For example, the command
ifconfig
will display information about the system’s network adapters:

And now we remember that everything is a file, including the display device (screen), so we just redirect the standard output stream instead of the screen to the file we need:
ifconfig> ~ /123.txt
After that, the command output will be saved to the 123.txt file in the user’s root directory.
Streams and pipeline
In the previous example, we touched on the standard output stream. Linux has standard I / O streams stdin , stdout and error output stderr for all processes . What does it mean? At least the fact that the process of data exchange between different processes is standardized. This allows pipelines to be created where the standard output of one command is piped to the standard input of another. For example, we want to see a list of installed packages on the system, in particular the squid packages. There is a command for this purpose:
dpkg -l
Eeee … What is this and how to understand something? Information about all the packages installed on the system quickly flashed on the screen, and all we can see is the “tail” of this output:

But we do not need all the output of this command, we are only interested in the iw packages. Therefore, we will direct the output of this command to the input of another, which will already select and show what we need:

Now that’s a completely different matter!
Moreover, the pipeline can be arbitrarily long, the result of the work of one command can be transferred to the second, from the second to the third, etc.
Big letters, small letters
Linux, like UNIX, is case sensitive. And this must be remembered! Because, unlike Windows, myfile.txt , Myfile.txt and myfile.TXT are three different files. For compatibility with other systems, do not abuse this and store files whose names differ only in case, and it is considered good practice to use only lowercase letters in names.
File extensions and types
In Windows systems, the file type is determined by its extension, if we rename the exe-file to jpg , then it will not start, and the system will try to process it as a picture. In Linux, the file type is determined by its content and the extension is used solely for compatibility with other systems or for user convenience. The ability to execute the file is ensured by setting the appropriate attribute. So in Windows, to make a script executable, you had to change the extension from txt to bat , in Linux, for this you need to make the file executable. Failure to understand this point leads to situations when a novice administrator does not understand why his myscript.sh script is not executed. Actually the extension.sh is needed only for convenience so that it is immediately clear that this is a Bash Shell script, and for it to work, it needs to set the executable attribute, and it can be called whatever you want.
Requirements
- a server running Ubuntu/Kali .
For different operating systems, the command line can be opened using applications:
- Mac OS X: Terminal (default), iTerm 2;
- Windows: PuTTY;
- Linux: Terminal, KDE Konsole, XTerm.
A detailed description of commands for Ubuntu can be found in the official documentation Ubuntu Command Line.
Login to the server through the terminal
In Ubuntu operating system, you can open the command line in two ways: through the console and through the graphical terminal.
To work through the console, press the key combination Ctrl+Alt+F1, to return to the graphical interface, press the key combination Ctrl+Alt+F7.
Press Ctrl+Alt+T to launch the terminal.

At the bottom of the screen is the command line prompt – a sequence of characters indicating that it is ready to process commands:
kalitut@kali:~$
where:
- kalitut is the name of the current user (superuser / administrator);
- Kali – hostname (server);
- : – separator;
- ~ – the current directory (in which folder the command is executed) of the user (by default / home /
- $ – the character of the input prompt for users with normal rights;
- # Is the prompt character for the superuser / administrator root (for example, root @ cs49647: ~ # ).
Basic commands used when configuring the server
After creating a new server, you need to take a few basic steps to configure it
To open the server under a logged in user account, enter the command:
ssh -p #port demo@adress
where:
- #Port – the number of the specified port during the initial server setup;
- demo – username;
- adress – server ip-address.

To log into the server as root, use the command, replacing SERVER_IP_ADDRESS with the public IP address of your server:
ssh root @ SERVER_IP_ADDRESS
To create a new user account, enter the command, replacing the DEMO name with whatever name you want:
adduser DEMO
To open the configuration file in a text editor as root, enter the command:
nano /etc/ssh/sshd_config
To replace the line in the opened configuration file, find, for example, the line Port 22 and replace the number 22 with any other number (from 1025 to 65536).
After making your changes, save and close the file by pressing CTRL-X, then Y, then ENTER.
To restart the SSH service, run the following command:
service ssh restart
To execute a command with root user privileges, precede it with the word sudo:
sudo command_to_run To end the session, run the command:
exit
Overview of commands, arguments and options for them
To run the command, enter the command and press the Enter key.
The commands are executed sequentially, to execute the next one, a command line prompt will appear (unless you use special scripts).
To open a page with a detailed description of a Linux command, for example ip address , enter the man command with the command name:
man ip address
Run without arguments and options
When running commands with no arguments:
- cd – return to the home directory of the current user;
- ls – displays a list of files and directories in the current directory.
Example:
By running the ls command without parameters, we get a list of files in the directory:
kalitut@kali:~$ ls
linux.jpg template ubuntu.jpg
Run with arguments (parameters)
Most commands are designed to be run with arguments (parameters).
The most common use of the cd command is to call with an argument, which is the path to the directory to change to:
cd /usr/bin
Launch with options
Many commands also support launch options (flags, keys) that allow changing the result of command execution. Options are a single character after the “-” character, or in extended spelling after “-“.
Example:
By running the ls command with the -A, -S, -1 options, we get a list of all files, including the “hidden” ones, located one on each line and sorted by size:
kalitut@kali:~$ ls -AS1
.gtkrc-2.0
linux.jpg
ubuntu.jpg
template
.filter
Run with arguments and options (simultaneously)
Command record structure with options and arguments:
command -options arguments
Example:
The ls -la / home command will print a verbose (-l) listing of the / home directory , including hidden files ( -a ):
kalitut@kali:~$ ls -la /home
total 12
drwxr-xr-x 3 root root 4096 Oct 14 16:13.
drwxr-xr-x 22 root root 4096 Oct 20 10:25 ..
drwxr-xr-x 4 testk testk 4096 Oct 19 10:52 testk
Environment variables
The environment / environment is a set of VAR = VALUE pairs that can be used by running processes.
Viewing environment variables
To view your environment, enter the command without arguments:
env
Depending on the system configuration, listing the environment variables can take several screens, so it is better to use the command:
env | more
Viewing the value of a variable
Environment variables can be formed from both uppercase and lowercase characters, but historically it was customary to name them in uppercase.
To display the value of an environment variable, just type echo $ VARIABLE NAME , for example, view the user’s home directory stored in the $ HOME environment variable :
echo $home
To go to the home directory, use the command:
cd $home
Setting environment variables
To set the values of an environment variable, enter the command:
var=value
where
- var – variable name;
- value – the value of the variable.
Example:
By executing the command var=value , after displaying it for viewing, we get the result value :

Linux Command Line Cheat Sheet
On/Off
- Restart the computer: reboot or shutdown -r
- Shutdown the computer: shutdown -h
- Shutdown the computer after the specified time:
- shutdown -h hh: mm
- shutdown -h + m
- End of the terminal session: exit
user management
- Enable root account: sudo passwd root
- Block root account: sudo passwd -l root
- Add user: adduser username
- Delete user: deluser username
- Delete user along with home directory: deluser username -remove-home
- Change username and its home directory name:
- usermod -l new user d /home/ new_user_name -m old_user_name
- Change user password: passwd username
- Restore the password for the system recovery account (press Esc while GRUB is booting): passwd write_name
Directory management
- Show information about file systems: sudo mount
- Show list of partitions: df
- Show contents of current directory: du -h
- Show size of specified directory: du -S directory_name
- Display path to current directory: pwd
- Create directory: mkdir directory_name
- Copy directory: cp directory_1 directory_2
- Move directory_m1 to directory_2 to directory dir: cd /dir_name
- Show directory contents: ls /dir_name
- Show directory contents, including hidden files and directories: ls -a /dir_name
- Show full directory contents: ls -l /dir_name
- Delete empty directory: rmdir dir_name
- Delete directory with contents: rm -r dir_name
Working with files
- Create a file in the current directory: touch file_name.txt
- Find file: locate file_name
- Update file search base: updatedb
- View text file: cat /path/file_name
- View text file in reverse order – from last line to first: tac /path/file_name
- Copy file_1 to file_2: cp file_2 file_2
- Move file_1 to file_2: mv file_1 file_2
- Move file while keeping the original (~ is appended to the end of the file name):
- mv -b file target_directory
- Delete file: rm file_name
- Write information to the file by overwriting it: echo text> file_name.txt
- Add information to the file without overwriting it: echo text >> filename.txt
- Merge multiple text files into one: cat file_1 file_2> final_file
Working with archives
- Create archive from directory contents: tar -cvf archive_name.tar directory_name/
- Compress files: bzip2 filename gzip filename zip filename
- Unpack archive: gunzip archive_name.tar
Access rights management
Example: -r — r —— dr — r —— The hyphen at the beginning means a regular file,
d — a directory (directory). Further, three groups of three characters each mean access rights for the owner, members of the group that the owner belongs to, and for all other users, respectively. Hyphen means no rights,
- r means read right,
- w – write right,
- x – execute right .
- View permissions: ls -l filename_or_directory_name
- Set permissions: chmod *** filename_or_directory_name
- where *** – permissions specified in an absolute way, or:
- chmod group = / + / – type of access filename_or_directory_name where group: u (user, owner) , g (group, group), o (other, others), a (all, all),
- for example: chmod a + rw filename Change owner: chown username filename filename Common Permissions: 644 = rw-r — r—
- 666 = rw-rw-rw-
- 777 = rwxrwxrwx
The order of the digits corresponds to the order of the users (ugo), the digit in each position is the sum of the values 4, 2 and 1 for the rights r, w and x, respectively. So the full access right for the owner and the absence of any rights for the group and other users will be 700 (4 + 2 + 1.0.0).
Program management
- Update the software list: apt-get update
- Update the system: apt-get upgrade
- Search the program in the repository by keyword: apt-cache search keyword
- Show package information: apt-cache show package_name
- Install the program from the repository: apt-get install package_name
- Remove the installed program: apt- get remove package_name
- Remove the program along with the configuration files: apt-get remove purge package_name
- Install the program from the compiled package: dpkg -i package_name.deb
- Remove the program: dpkg -r package_name.deb
- Clear the local repository of the received package files: apt-get clean
- List installed packages: dpkg – l
- Add private software source PPA (Personal Package Archive): add-apt-repository ppa:user / ppa-name
- Install the program from a binary file (you must first go to the directory with the program file): ./file_name.bin Allow execution of the file (if necessary): chmod a + x filename.bin />
- Install the program from source files (you must first go to to the directory with the program file): ./configure
- make
- make instal
- Remove the program installed from the source files: make uninstall Run a graphical program as root: gksudo program_name
System management
- Display a list of registered users: who
- Display information about the use of RAM: free
- Display a list of running processes: ps
- Kill a process: killall process_name
- Display a list of processes in real time: top
- Modify the configuration file gedit /path/to_file
- Reduce disk read speed in the drive: hdparm -E 4 /dev/dvdrom
System diagnostics
- Check the hard disk for bad sectors: badblocks
- Show the status of network interfaces: ifconfig
- Show the status of wireless network devices: iwconfig
- Check the routing table: route
- Check the availability of the computer in the network: ping site_name_or_ip_address Stop the process: Ctrl + C
- Check the packet route: traceroute_ip_name-
- show information about the connected USB devices: lsusb
- Display a list of PCI buses and devices connected to them: lspci
- Display a list of system hardware: lshw
Getting help
- Display An introduction to custom commands: man intro
- Display a short description of a command: whatis command_name
- Display information about a command: man command_name info command_name command_name —help
- Find information by keywords: man -k keyword_word Search by page: /keyword_word Continue search: N
- Display command history from command history: Execute command history ! command_number! first_command_ letters
- Clear console screen: clear
Combining teams
- Sequential execution of commands: command1; command2
- Consecutive execution of commands on condition of successful execution of the previous command: command1 && command2
- Consecutive execution of commands on condition of failure of the previous command: command1 || command2
- Sequential execution of commands with the transfer of the results of the previous command to the next one: command1 | command2
- Run command in background: command &
Wildcard characters
- Current directory: .
- Parent directory: ..
- User home directory: ~
- One arbitrary character:?
- Any number of arbitrary characters: *
- A character from the specified range: [a, b, xz], for example, [a, b].rar
- Any characters except the specified ones: [! Ab], for example, [! Ab].rar
- Brace substitution: for example, {a, b} {1,2} will create a string a1 a2 b1 b2
- Specifying a special character: either an apostrophe, such as ‘file name’, or a file name
Basic Linux commands
Below I will briefly review some of the basic Linux commands (utilities) and their options that you often have to use when working at the command line. I will give some commands with examples, and some just with a short description.
ls – print filenames
The ls utility is designed to display a list of files and directories in the current directory. Let’s take a look at some of the useful properties of the ls command.
- -A – include in the list “hidden” files (“hidden” files in Linux have a dot at the beginning of the file name in their name, for example, .gtkrc-2.0).
- -S – sort files by size.
- -t – sort by modification date.
- -1 – output names in a column, one on each line.
- -l – display detailed information about each file, file size, file owner, access rights, modification date.
Now I will give a few examples. If you run the ls command with no parameters, you just get a list of the files in the directory.
Kalitut@kali:/$ ls
fonts.tar.gz linux.jpg report.odt template ubuntu.jpg
Now let’s execute the command with the options -A, -S, -1. As a result, we get a list of all files, including the “hidden” ones, located one on each line and sorted by size.
Kalitut@kali:/$ ls -AS1
fonts.tar.gz
.gtkrc-2.0
linux.jpg
report.odt
ubuntu.jpg
template
.filter
Run the ls command with the -l option. Let’s get detailed information about each file.

mkdir – create directory
The mkdir command is for creating a new directory.
To create a new directory,
mkdir directory_name
To create several directories at once, specify their names separated by a space, for example: mkdir mydir1 mydir2 mydir3
cp – copy file
The cp utility is used to create a copy of a file. For normal copying, the following syntax is used.
cp <file name source> <file name destination >
There is one thing to remember when using cp. If the destination file already exists, then cp will overwrite it. Therefore, to avoid accidentally deleting an existing file, use the cp command with the -i option. Before overwriting the file, you will be asked for your consent.
For example, if we copy the linux.jpg file to the windows.jpg file and windows.jpg already exists, then a request will be issued to overwrite the file:
Kalitut@kali:/$ cp -i linux.jpg windows.jpg
cp:overwrite `windows.jpg '? y
The -r (or -R) option is used to copy one directory to another.
mv – move, rename a file
The mv utility is designed to move, rename a file.
To rename a file, use the syntax
mv <file name> <new name file >
To move a file to another directory, use the syntax
mv <file name> <directory>
You can also use the -i option with mv to avoid accidentally overwriting an existing file.
rm – delete a file
The rm command is for deleting files. Main command options:
-i – prompt before deleting each file. -r (or -R) – remove directories and their contents.
cd – change current directory
The cd command is for changing the directory you are currently in. For example, you are currently in your home directory ~ and want to change to the ~ / information directory, then you just need to run the command cd information.
Kalitut@kali:/$ cd information
Kalitut@kali:/information$
If you run cd without parameters, you will be taken to your home directory ~.
Kalitut@kali:/information$ cd
Kalitut@kali:~$
To move to a directory one level higher (the parent directory), you can use the synonym “two dots” – .., which in Linux are synonymous with the path of the parent directory. For example, while in the ~/information directory, we can change to the ~ directory like this:
Kalitut@kali:~/information$ cd ..
Kalitut@kali:~$
cat – output file contents
The cat utility displays the contents of a text file.
The simplest syntax for the command is cat <filename>.
The cat utility can be used to concatenate the concatenation of two text files, hence the name of the utility (catenation, concatenation).
For example, we have two files filetxt and file2, each with two lines.
First, we will output the contents of the files separately, and then we will concatenate the two files



pwd – display the full path of the current directory
The pwd command is used to display the full path of the current directory.

man – get manual
The system utility man displays the system documentation pages. With its help, you can get information on any Linux commands. To do this,
use the syntax: man <utility name>
For example, to display the manual for the ls utility:
man ls
Intermediate commands
1. echo – the “echo” command helps us move some data, usually text, into a file. For example, if you want to create a new text file or add to an already created text file, you just need to enter “echo hello, my name is hich >> new.txt”. You don’t need to separate spaces with backslashes here because we enclose in two triangular brackets when we finish what we need to write.
2. cat – Use the cat command to display the contents of a file. Usually used for easy viewing of programs.
3.nano, vi, jed – nano and vi already have text editors installed on the Linux command line. The nano team is a good text editor that color coded keywords and can recognize most languages. And vi is simpler than nano. You can create a new file or modify a file using this editor. For example, if you need to create a new file called “check.txt”, you can create it with the “nano check.txt” command. You can save your files after editing using the sequence Ctrl + X then Y (or N for no). In my experience, using nano to edit HTML doesn’t look good because of its color, so I recommend jed a text editor. We will start installing packages shortly.
4. sudo is a widely used command on the Linux command line, sudo stands for “SuperUser Do”. Therefore, if you want any command to be run as administrator or root, you can use the sudo command. For example, if you want to edit a file like viz. alsa-base.conf which requires root privileges, you can use the command – sudo nano alsa-base.conf. You can enter the root command line using the “sudo bash” command and then enter your user password. You can also use the “su” command, but before that you need to set the root password. To do this, you can use the “sudo passwd” command (not misspelled, it’s passwd). Then enter the new root password.
5. df – Use the df command to see the available disk space on each of the partitions on your system. You can just type df at the command line and see each mounted partition and its used / available space in% and in kilobytes. If you want it to be displayed in megabytes, you can use the “df -m” command.
6. du – Use du to see how a file is being used on your system. If you want to know the amount of disk space used for a specific folder or file in Linux, you can enter the df command followed by the folder or file name. For example, if you want to know the amount of disk space used by the documents folder in Linux, you can use the “du Documents” command. You can also use the “ls -lah” command to view the sizes of all files in the folder.
7. tar – Use tar to work with tarballs (or files compressed in the archive tarball) in the Linux command line. It has a long list of uses. It can be used to compress and decompress various types of tar archives such as .tar, .tar.gz, .tar.bz2 , etc. This works based on the arguments given to it. For example, ” tar -cvf ” to create a .tar archive, – xvf to unpack a .tar archive, – tvf to view the contents of an archive, etc.
8.zip, unzip – use zip to compress files into zip archive and unzip to extract files from zip archive.
9. uname – Use uname to show information about the system your Linux distribution is running on. Using the “uname -a” command prints out most of the information about the system: kernel release date, version, processor type, etc.
10.apt-get– use apt to work with packages on the Linux command line. Use apt-get to install packages. This command requires superuser rights, so use the sudo command with it. For example, if you want to install the jed text editor (as I mentioned earlier), we can enter the command “sudo apt-get install jed”. Likewise, any packages can be installed as follows. It is recommended that you update your repository every time you try to install a new package. You can do this by typing “sudo apt-get update”. You can upgrade your system by typing “sudo apt-get upgrade”. We can also upgrade the distribution by typing “sudo apt-get dist-upgrade”. The “apt-cache search” command is used to search for a package. If you want to find it, you can type “apt-cache search jed” (it doesn’t require root).
11. chmod – Use chmod to make the file executable and change the permissions given to it in Linux. Imagine you have Python code named numbers.py on your computer. You will need to run “python numbers.py” every time you need to run it. Instead, when you make it executable, you just need to run numbers.py in a terminal to run the file. To make the file executable, you can use the command “chmod + x numbers.py” in this case. You can use “chmod 755 numbers.py” to give it root privileges, or “sudo chmod + x numbers.py” for the root executable. Here’s some more information about the chmod command.
12. hostname – Use the hostname command to find out your name on your host or network. Basically, it displays your hostname and IP address. Just typing “hostname” will give you the hostname. By typing “hostname -I”, you will get your IP address on the network.
13. ping – use ping to test your connection to the server. Wikipedia says, “Ping is a computer network administration utility used to check the availability of a host on an Internet Protocol (IP) network.” For example, when you type, ” ping google.com “, it checks to see if it can connect to the server and come back. It measures this round trip time and gives you detailed information about it. You can also use this command to test your internet connection. If it pings the google server (in this case) – the internet connection is active!
Tips and tricks for using the Linux command line
- You can use the clear command to clear the terminal if there are too many commands accumulated there.
- TAB can be used to fill in the terminal. For example, you just need to type “cd Doc” and then TAB and the terminal fills in the rest and makes it “cd Documents”.
- Ctrl + C can be used to safely stop any command in the terminal. If Crtl + C didn’t work, then you can use Ctrl + Z to stop the process running in the terminal.
- You can exit the terminal using the exit command .
You can shutdown or restart your computer using the sudo halt and sudo reboot commands .
Leave a Reply