View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

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

  1. man - prints documentation on other commands
  2. pwd - prints current working directory
  3. ls - prints directory contents
  4. cd - changes current directory
  5. mkdir - creates a new directory
  6. file - determines file type
  7. echo - prints messages to the standard output
  8. cp - copies files and folders
  9. mv - renames or moves files or folders
  10. rm - deletes files or folders
  11. su - run a command with substitute user (e.g. root)
  12. exit - causes Bash to exit
  13. uname - print system information
  14. which - locate a command

Installing additional programs in Linux Ubuntu

Midnight Commander file manager:

acos@acos-vm:~$ sudo apt install mc
  1. sudo helps execute a command as a superuser
  2. apt is a Linux package manager

Creating, editing and viewing source code:

  1. cat - concatenates and prints text files
  2. head - outputs the first part of files
  3. tail - outputs the last part of files
  4. nano - simple console code editor
  5. mcedit - mcedit simple editor from Midnight Commander
  6. vim - 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