Add a Python web server on the fly to our project

If you are on linux / OsX or inside a phyton environment you can start a web server on the fly inside your project simply recalling an alias from the terminal in your project folder.

You have to edit your bash profile and add the following line:

This feature is very useful when you are working in local host with a browser that disables the origin load by default (i.e. Chrome).

inserted the alias inside the .bash_profile, refresh with the following command:

inside your project folder you just type $ server to open your web server.

Customise your terminal bash prompt

If you are using OSX this is wonderful because you can customise your command line by adding emoji icons to the bash prompt.

You can find icons inside your Edit menu: Edit -> Emoji & Symbols.

Emoji and Symbols
EDIT -> Emoji and Symbols

 

How to add custom icons to our bash?

So edit your .bash_profile with your favourite editor vim, nano for example, and add the line:

PS1=" "

Open Emoji & Symbol panel and drag and drop your favorite emoji inside quotation marks.

Grag Emoji
Drag emoji inside quotation marks

Depending on terminal settings, nothing may be visible after using drag & drop. Close and reopen you terminal and voilà:

terminal-hbYou can customise terminal bash with some others options:

\d Current date
\t Current time
\h Host name
\# Command number
\u User name
\W Current working directory (ie: Desktop/)
\w Current working directory with full path

This is my favourite customisation:

PS1="🌀  \[email protected]\h\W$ "

What’s yours?

enable ssh: centos

#install:

#start the service

#status
service sshd status

#allow user: AllowUsers user_name and restart: service sshd restart

more in the wiki here.

sudoers grant

For grant sudoers to user in redhat, centos, oralce linux, edit the file /etc/sudoers and append
username ALL=(ALL) ALL
under
root ALL=(ALL) ALL

For example:

less command

The navigation keys in less command are similar to Vim editor.

Forward Search

Backward Search

For viewing large log files

Useful other command

File paging
You can open multiple files by passing the file names as arguments:

virtualbox: mount shared esterno su linux

You have to specify the path and folder to share with the service name on virtualBox

for the mount you can use this command:

sudo mount -t vboxsf nome_servizio /shared_name

you need on your linux OS one folder (mkdir shared_name)

for example if the service name is “stage” and the folder name on the system is shared you can use this command:

sudo mount -t vboxsf stage /shared

for the unmount you can use:

sudo umount -t vboxsf stage /shared

tar.gz

#archive the file without compression.
tar file_name
Options:

(1) create tar cfv tar c=create, f=file (on the disk and not on the tape),v=verbose (show file list).

ex: tar cfv archive.tar *.txt create the file’s archive of all txt files in the same path.

ex: tar -cvf /destination_path/filename.tar /path to put in the tar file

(2) tvf to show the content of the archive: tar tfv archive.tar

(3) xfv archive file extraction: tar xfv archive.tar