Useful Linux Commands – System

These are some really useful commands to know in the Linux terminal.

System Command

Reboot the System

Reboot the system immediately:

Reboot the system after 10 minutes:

Reboot the system after 10 minutes and send a message to all user:

Check last reboot time:

Display information about running processes

ps command is used to display information about the processes that are running in the system.

The output will show:

  • PID = the process ID that identify the running process
  • TTY = ┬áthe Terminal type
  • TIME
  • CMD

You can add the -ef option to get the full list (-e option show all the processes, -f option show full details):

or add -eF to view more and more details:

Show the top running processes

The command top show the top running process in your system.

The output show information like the user, memory usage, CPU usage, running time, command lunched… You can sort the list pressing SHIFT+O.

Start or stop a service

To check the current status of a service (with the service name in SERVICE_NAME) run:

For example, to check the status of samba service:

To run a service use:

or to stop:

or to restart:

If you want to check set status of all running processes:

Know free memory

To know free memory in your system type:

The output is displayed in bytes:

Search for a given string

The grep (general regular expression print) command allow to search for a given string in a file or output of another command.

To search a string in a given file type:

For example, to search the word “express” (case insensitive, option -i) in the file app.js:

The output will be:

The grep command is very useful. Please, consider to read the full article here.

Show system environmental variables

To show the system environmental variables use the command export:

The output can be really confusing. If you need to search for a given string, combine the export command with grep:

Export a system environmental variable

Use again the export command, with the variable to export:

For example to export the JAVA_HOME:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *