Categories
Fun

Watch Star Wars in Terminal Definition

Are you a Star Wars fan?

Watch our favorite movie in a true real experience: the Terminal Definition.

Before to start, be sure to have a Terminal Definition Display and a Fiber Internet connection.

Let’s go!

  1. Open your terminal
  2. Type the following command:
    telnet towel.blinkenlights.nl
  3. Enjoy the movie!

Star Wars in Terminal Definition

How to exit from the movie? Type CTRL+] while watching the movie. The telnet console will show. Now type quit and the connection will be closed.

 

Categories
Linux

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:

shutdown -r now

Reboot the system after 10 minutes:

shutdown -r +10

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

shutdown -r +10 "The system is rebooting in 10 minutes. Please, save your work."

Check last reboot time:

last reboot

Display information about running processes

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

ps

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):

ps -ef

or add -eF to view more and more details:

ps -eF

Show the top running processes

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

top

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

top - 16:13:47 up 6 days, 18:56,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 130 total,   1 running, 129 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   949572 total,   120876 free,   140968 used,   687728 buff/cache
KiB Swap:   102396 total,   101380 free,     1016 used.   729356 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND    
  362 stefano   20   0  399000  73304   9344 S   1.0  7.7  65:40.04 java       
 6395 stefano   20   0    8100   3180   2704 R   1.0  0.3   0:00.10 top        
 3070 mongodb   20   0  372996  41672  13452 S   0.3  4.4  37:33.36 mongod     
    1 root      20   0   28108   6116   4884 S   0.0  0.6   0:16.58 systemd    
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.16 kthreadd   
    3 root      20   0       0      0      0 S   0.0  0.0   0:20.76 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+
    7 root      20   0       0      0      0 S   0.0  0.0   0:45.95 rcu_sched  
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh     
    9 root      rt   0       0      0      0 S   0.0  0.0   0:00.11 migration/0
   10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-dr+
   11 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0    
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1    
   13 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 migration/1
   14 root      20   0       0      0      0 S   0.0  0.0   0:13.24 ksoftirqd/1
   16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:+
   17 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2    

Start or stop a service

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

service SERVICE_NAME status

For example, to check the status of samba service:

service samba status

To run a service use:

service SERVICE_NAME start

or to stop:

service SERVICE_NAME stop

or to restart:

service SERVICE_NAME restart

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

service --status-all

Know free memory

To know free memory in your system type:

free

The output is displayed in bytes:

              total        used        free      shared  buff/cache   available
Mem:         949572      140332      121768       13716      687472      729976
Swap:        102396        1016      101380

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:

grep -I "STRING_TO_SEARCH" FILE_TO_BE_SCANNED

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

grep -i "express" app.js

The output will be:

var express = require("express");
    session = require("express-session"),
var app = express();
app.use(express.static(path.join(__dirname, "public")));

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:

export

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

export | grep JAVA

Export a system environmental variable

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

export VARIABLE_NAME=VALUE

For example to export the JAVA_HOME:

export JAVA_HOME="/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/
Categories
Raspberry Pi

Share a folder via Samba on Raspberry Pi 3

Share a folder from Raspbian 9 (stretch) is pretty simple.

Check samba status

You need to check if samba already installed and running.

Type in your terminal:

$ samba --version

The output must be the version number of the installed samba version:

$ Version 4.5.12-Debian

To check if it’s running, type (you mast be root or sudoers):

$ sudo smbstatus

If samba is running it will show different information on the service PID, user, machine, shred folders and so on. In this case skip the next paragraph.

Install samba server

If samba is not correctly installed type (you mast be root or sudoers):

$ sudo apt-get install samba samba-common-bin

Configure your samba server

It’s now time to configure your samba server.

Let’s go to edit the smb.conf located in /etc/samba (I’ll use nano editor). Type:

$ sudo nano /etc/samba/smb.conf

Change the following entries:

workgroup=WORKGROuP  # This must be set with your workgroup. Leave if you don't know.
wins support=yes # Wins is support to Windows machine. Leave if you don't need it.

and ADD to the end of the file the share setting for your folder:

[SHARE_FOLDER_NAME]
comment = ANY_COMMENT
path= PATH_OF_THE_SHARED_FOLDER
browseable=yes
read only = no
writeable=yes
only guest=no
guest ok=no
create mask=0777
directory mask=0777
public=no

Where SHARE_FOLDER_NAME is the name you want to give to this share, ANY_COMMENT is just a comment, PATH_OF_THE_SHARED_FOLDER is the path of the folder to share (for ex. if I want to share my home folder it is: /home/stefano ).
To save just press CTRL+X and confirm with Y.

Setup a password

It’s time to setup a password for your user. Type:

$ sudo smbpasswd -a username

where username is your local username. Provide a new password.

Restart the server

To restart the server and make all change available, type:

$ sudo /etc/init.d/samba restart

Connect to your share

Now you can try to connect to your samba server.

For example: in Mac OS X you can press from a Finder window Command+k (+k). In the server address type smb://IP_ADDRESS_OF_YOUR_SERVER/SHARE_FOLDER_NAME and provide your Username and your Password that you previously created.

Enjoy.