Linux systems are powerful operating systems with endless possibilities. However, learning to use this amazing OS can be difficult if you’re new to the Linux world.
You could spend days browsing through forums, copy/pasting code and never really knowing what’s going on or why it works. If you want to learn commands, I recommend this site.
Enter the Command Line
My first tip is pretty basic, but very important. Before you can run any of these commands, you’ll need to start the terminal.
One way is to enter the terminal outside of the GUI. X11 or Wayland provides the graphical user interface on linux. You can switch to the terminal by pressing Alt+Ctrl+F1 to F12.
You can also start a graphical terminal. There are many variants like gnome-terminal, konsole, xterm, kitty and many others.
The Linux Command Line is a powerful tool every programmer should know, even if they don't use linux. It is also a dangerous weapon that can lead to potential disaster if it is used improperly. So, which are the essential commands that a programmer needs to know?
The mkdir command
The mkdir command allows you to create directories. You can also give it an optional -p flag to create any needed parent directories along with the directory itself.
The ll command
The ll command lets you see the files and folders in a directory. It has several useful options such as showing the file size, permission mode, and more.
$ ll total 2097256 drwxr-xr-x 20 root root 4096 jun 4 2021 ./ drwxr-xr-x 20 root root 4096 jun 4 2021 ../ lrwxrwxrwx 1 root root 7 jun 4 2021 bin -> usr/bin/ drwxr-xr-x 4 root root 4096 mei 28 18:31 boot/ drwxrwxr-x 2 root root 4096 jun 4 2021 cdrom/ drwxr-xr-x 21 root root 4780 mei 28 20:43 dev/ drwxr-xr-x 153 root root 12288 mei 28 18:31 etc/ drwxr-xr-x 3 root root 4096 apr 6 14:20 home/ lrwxrwxrwx 1 root root 7 jun 4 2021 lib -> usr/lib/ lrwxrwxrwx 1 root root 9 jun 4 2021 lib32 -> usr/lib32/ lrwxrwxrwx 1 root root 9 jun 4 2021 lib64 -> usr/lib64/ lrwxrwxrwx 1 root root 10 jun 4 2021 libx32 -> usr/libx32/ drwx------ 2 root root 16384 jun 4 2021 lost+found/ drwxr-xr-x 3 root root 4096 apr 24 15:24 media/ drwxr-xr-x 2 root root 4096 feb 9 19:47 mnt/ drwxr-xr-x 2 root root 4096 feb 9 19:47 opt/ dr-xr-xr-x 269 root root 0 mei 28 19:10 proc/ drwx------ 10 root root 4096 mei 23 20:00 root/ drwxr-xr-x 35 root root 920 mei 28 20:02 run/ lrwxrwxrwx 1 root root 8 jun 4 2021 sbin -> usr/sbin/ drwxr-xr-x 17 root root 4096 mei 25 01:18 snap/ drwxr-xr-x 2 root root 4096 feb 9 19:47 srv/ -rw------- 1 root root 2147483648 jun 4 2021 swapfile dr-xr-xr-x 13 root root 0 mei 28 19:10 sys/ drwxrwxrwt 20 root root 20480 mei 28 21:19 tmp/ drwxr-xr-x 14 root root 4096 feb 9 19:48 usr/ drwxr-xr-x 14 root root 4096 feb 9 19:56 var/
The cd command 😁
cd (change directory) command lets you move around within your Linux filesystem.
You'll find yourself using it constantly. Here's an example of how it works:
cd Documents cd Linux\ Box\ Archive cd
To list files, type
The rm command
The rm command removes files and folders. It removes it completely from your system, it doesn't put it in a trash can.
rm -rf folder
Copies files and directories within the same directory or between two directories
cp [option] [source] [target]
cp mydoc.doc mydoc_new.doc
Linux tree command 💻
The tree command provides us with a way to get an overview of files and folders and how they are structured in our directories. The tree command is used like that: tree
$ tree -d -L 1 . ├── bin -> usr/bin ├── boot ├── cdrom ├── dev ├── etc ├── home ├── lib -> usr/lib ├── lib32 -> usr/lib32 ├── lib64 -> usr/lib64 ├── libx32 -> usr/libx32 ├── lost+found ├── media ├── mnt ├── opt ├── proc ├── root ├── run ├── sbin -> usr/sbin ├── snap ├── srv ├── sys ├── tmp ├── usr └── var
If you change it to L2, it goes a level deeper. There is no limit to how many levels you can go.
$ tree -d -L 2 ... ├── usr │ ├── bin │ ├── games │ ├── include │ ├── lib │ ├── lib32 │ ├── lib64 │ ├── libexec │ ├── libx32 │ ├── local │ ├── sbin │ ├── share │ └── src └── var ├── backups ├── cache ├── crash ├── lib ├── local ├── lock -> /run/lock ├── log ├── mail ├── metrics ├── opt ├── run -> /run ├── snap ├── spool └── tmp
vim is an editor which is popular among programmers, especially among Linux enthusiasts.
Vim or it's older variant vi is everywhere, on Mac OS X, on servers etc. It has quite a steep learning curve, you can practice by exercise
To exit vim press ZQ.
grep in files
Using the command
grep, we can search for a specific character pattern inside a file or files.
You can use it like:
grep word filename
This commands allow you to compare file contents to see if their contents are equal, or to test if the file has been changed in any way.
It creates a unique hash for the file contents. This way you can check if the file has been changed if you send it over the internet.
This returns a unique hash for the file.
the ifconfig command
This command is used for network configuration. If you want to assign a static IP address, you need to use this command
Top comments (0)