Basic Linux Command Line
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.
Command Line
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:
- Ghaziya : Username currently logged in and active.
- Localhost : The name of the computer or *hostname *where ghaziya the current login.
- ~ : This symbol indicates the location of the current directory, usually the home for the user directory (ghaziya).
- $ : This means iqbal and is an account with normal user level, limited ability. This will change to [#] if you login with the highest level root account.
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].
Get to know the Text Mode Environment
Here are some commands that can be used to find out our linux work environment.
Whoami - Know Who I am
This will display the account that is currently in use.
$ whoami
Hostname - Knowing the Computer Name
This command will display the name of the computer we are using.
$ hostname
SU - Substitute user (Changing User Account)
This command is used to replace active users now with other accounts.
Shutdown - Turn Off Computer
Sometimes we want to shut down the computer quickly and no longer use the GUI, then this shutdown command can be used.
Directories and Files
The commands below can be used to work with directories and a list of the files it contains.
ls - View Directory Contents
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.
pwd - Find out Active Directory
The command is useful to see the active directory that is being used by the user, this [pwd] means print working directory.
cd - Changing Active Directory Locations
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.
mkdir - Create a New 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
cp - Copying Directories and Files
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
mv - Move a file or rename
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
rm - Delete Files and Directories
This command is used to delete a file or a directory.
$ rm file / which / want / deleted
cat - Displays the contents of a text file
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
more - Displaying Text File Contents is limited to the monitor page
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.
less - Also just like more but better still.
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.
tail - View the contents of the file from the last line
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
head - The opposite of `tail '
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 ;
find - Search for file location
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
### Viewing and Controlling Processes in Linux In Linux Terminal, we can see the running process, set the priority scale, or run it on the back screen, or stop it.
ps - View the running process
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
kill - Stops a process
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.
Conclusion
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.
Best regards, @ghaziya.
Resteemed by @resteembot! Good Luck!
The resteem was paid by @greetbot
Curious?
The @resteembot's introduction post
Get more from @resteembot with the #resteembotsentme initiative
Check out the great posts I already resteemed.
Shutting down is ridiculously useful for me. At night if anyone wants to listen to music or a podcast but they don't want to turn off the computer manually when it's done and can just fall asleep, a simple shutdown -t 80 should give most people enough time.