Linux Utility Programs and Bash
Unix-based systems (such as Linux and MacOS) provide utility programs to perform various systems tasks. These utilities are used via command-line interface. Bash is command-line processor and language used to execute these command. Bash is supported in Linux and MacOS. In Windows, a limited support is implemented in Windows PowerShell Git Bash. Also, some of the commands are implemented in Terminal of JetBrains IDEs (PyCharm, IntelliJ IDEA, CLion, etc.).
Main Bash commands
man- prints documentation on other commandspwd- prints current working directoryls- prints directory contentscd- changes current directorymkdir- creates a new directoryfile- determines file typeecho- prints messages to the standard outputcp- copies files and foldersmv- renames or moves files or foldersrm- deletes files or folderssu- run a command with substitute user (e.g. root)exit- causes Bash to exituname- print system informationwhich- locate a command
Installing additional programs in Linux Ubuntu
Midnight Commander file manager:
acos@acos-vm:~$ sudo apt install mc
sudohelps execute a command as a superuseraptis a Linux package manager
Creating, editing and viewing source code:
cat- concatenates and prints text fileshead- outputs the first part of filestail- outputs the last part of filesnano- simple console code editormcedit- mcedit simple editor from Midnight Commandervim- Vi IMproved, a programmer’s text editor
Compiling and running programs in C
Use the following commands (work in MacOS too).
Compiling:
gcc hello.c -o hello.c
Running:
./hello
Measuring performance with the time utility:
time ./hello
Getting information on CPU configuration
Using utility lscpu:
lscpu
Viewing virtual file /proc/cpuinfo:
less /proc/cpuinfo
Getting information on the computer and OS
Using utility uname to get system information:
uname -a
Viewing virtual file /proc/version:
cat /proc/version
Using utility hostnamectl to get information on the computer:
hostnamectl