Linux as an operating system, provides an attractive Graphical User Interface to make Linux users work in Linux environments, making Linux look more user-friendly, both new users and older users who work with Graphics.
Besides providing an interesting GUI, Linux as an operating system also provides a text-based work environment, often called Terminal or often called Command Line Interface (CLI). The appearance is just the command line that sometimes black can sometimes white, but has a high efficiency and effectiveness of work if you understand to use it. For beginners, this CLI looks a bit spooky, but if you try to learn and understand, the work so much faster and fun, guaranteed to be addicted.
In this first part, I will try to describe the text mode and some basic Linux commands that must be understood in the Linux terminal environment.
If we are used to using Windows operating system, of course we often hear or use the command prompt, if the Linux name Shell prompt. More or less the same terminal, but have different formats and functions, the commands are also very different.
Terminals on Linux can be accessed via the Applications menu -> System Tools -> Terminal
[Ghaziya@localhost ~] $
the purpose of the above symbols is as follows:
Note that the command on the Linux terminal is case sensitive, meaning lowercase and uppercase letters will be different results, [ls] different results with [Ls].
Here are some commands that can be used to find out our linux work environment.
This will display the account that is currently in use.
$ whoami
This command will display the name of the computer we are using.
$ hostname
This command is used to replace active users now with other accounts.
Sometimes we want to shut down the computer quickly and no longer use the GUI, then this shutdown command can be used.
The commands below can be used to work with directories and a list of the files it contains.
To see a list of files in active directory, you can use this command, [ls] means list. This command is the same as the Dir command on Windows.
The command is useful to see the active directory that is being used by the user, this [pwd] means print working directory.
Sometimes we want to move from one active directory to another directory, this [cd] command is very useful to move from one directory to another directory.
This command can be used to create a new folder, usually through GUI, can be done with right click, create new folder, try to imagine if we want to create many directories at once, this command [mkdir ] solution.
[$ mkdir steemit] means you will create a folder called [steemit].
[$ mkdir steemit utopian opensource] means we will create three folders at once ie [steemit], [utopian] and [opensource]. This [mkdir] command also allows us to create a folder that is hierarchical, meaning that in the folder there is a folder by using the -p parameter.
$ mkdir -p steemit/utopian/opensource
This [cp] command is used to spice one file from one place to another. This process is done by reading the source file and doing the creation of a new file in the destination directory.
$ cp source destination
In contrast to previous commands, [mv] can be used to move a file from source to destination, or it can also be used to rename a single file or folder.
$ mv source destination
This command is used to delete a file or a directory.
$ rm file / which / want / deleted
The [cat] command is used to view the contents of a file and displayed on the monitor screen. For small file sizes, this command is still suitable for use, such as
$ cat / etc / fstab
If the [cat] is only suitable to bring a small file, then more can be used to view files with a larger size that will not fit in one screen. You can press enter key or space key to see next page.
The downside, we can not see the previous page.
Why do I say better? If more can not see back the page read, then less can see the page that has been passed by page down or page up.
As SysAdmin, sometime that needs to be seen only the last few lines of a log, this [tail] command is perfect for use.
$ tail /etc/passwd
messagebus:x:109:112::/var/run/dbus:/bin/false
usbmux:x:110:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false
geoclue:x:111:115::/var/lib/geoclue:/bin/false
speech-dispatcher:x:112:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false
pulse:x:113:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false
avahi:x:114:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
colord:x:115:120:colord colour management daemon,,,:/var/lib/colord:/bin/false
saned:x:116:121::/var/lib/saned:/bin/false
Debian-gdm:x:117:122:Gnome Display Manager:/var/lib/gdm3:/bin/false
user:x:1000:1000:Debian Live user,,,:/home/user:/bin/bash
If we just want to see the last 4 lines of /etc/passwd, then it can be done with the command ;
$ tail -4 /etc/passwd
colord:x:115:120:colord colour management daemon,,,:/var/lib/colord:/bin/false
saned:x:116:121::/var/lib/saned:/bin/false
Debian-gdm:x:117:122:Gnome Display Manager:/var/lib/gdm3:/bin/false
user:x:1000:1000:Debian Live user,,,:/home/user:/bin/bash
If the tail command above just to see the end line only, then the head is used to see the beginning of the line as text.
$ head /etc/passwd
If you only want to see the first 3 lines only, it can be done with the command ;
Finding a file or directory manually is very hard work. It would be harder if we do not know exactly the name of the file and directory to be searched. The [find] command is a very useful command and is very often used to search for files or directories among hundreds of thousands of files in a computer.
$ find /var/log
This command can be used to view the processes that are running on the computer.
[$ ps] the result will look like this ;
PID TTY TIME CMD
1597 pts / 0 00:00:00 bash
19600 pts / 0 00:00:00 ps
If it does not use any parameters, then by default, ps only displays a list of processes that are run by the account being used in a terminal session. To display the process of all accounts and all active sessions, use;
$ ps -ef | more
This kill command can be used to stop a process that you want to stop, or any process that is crashing. This kill command must be followed by the PID of the program to be stopped, PID can be obtained with the previous ps command.
$ kill 880 let's say i want to turn off gdm-session that has PID 880, then kill command will immediately stop gdm-session process.
Understanding and using Linux terminals really helps the user in terms of effectiveness and efficiency work, hopefully writing about some basic commands in this Linux terminal can be useful for Linux users, both new and advanced Linux.