Skip to content

Instantly share code, notes, and snippets.

View gbarreiro's full-sized avatar

Guillermo Barreiro gbarreiro

View GitHub Profile
@gbarreiro
gbarreiro / provincias_españa.csv
Last active May 7, 2021 13:54
Provincias y Comunidades Autónomas de España
provincia iso comunidad autónoma
A CORUÑA C Galicia
ALBACETE AB Castilla-La Mancha
ALICANTE A Comunidad Valenciana
ALMERIA AL Andalucía
ARABA/ALAVA VI País Vasco
ASTURIAS O Asturias
AVILA AV Castilla y León
BADAJOZ BA Extremadura
BARCELONA B Cataluña
@gbarreiro
gbarreiro / bash_cheatsheet_path.sh
Last active December 6, 2020 20:55
Bash cheatsheet: path
export PATH=$PATH:/home/john/myprogram # add the directory /home/john/myprogram to the path
which nano # shows where is the executable of "nano" located
whereis nano # shows where are the executable, manuals, source code, etc. of "nano"
@gbarreiro
gbarreiro / bash_cheatsheet_alias.sh
Created December 6, 2020 20:45
Bash cheatsheet: alias
alias clone_my_repo = "git clone http://verylongurl.com" # create an alias
@gbarreiro
gbarreiro / bash_cheatsheet_variables.sh
Created December 6, 2020 20:43
Bash cheatsheet: variables
echo "hello" # prints hello in the console
echo $USER # prints the value of the variable USER in the console
env # prints all the environment variables
set # prints all the local variables
MY_FRIENDS=William # create a local variable called MY_FRIENDS
MY_FRIENDS=$MY_FRIENDS:John:Anna # concatenate values 'John' and 'Anna' to MY_FRIENDS
export MY_FRIENDS # makes local variable MY_FRIENDS an environment one
unset MY_FRIENDS # deletes the variable MY_FRIENDS
@gbarreiro
gbarreiro / bash_cheatsheet_pipes.sh
Created December 6, 2020 20:39
Bash cheatsheet: pipes
a | b # pipe: inject a command output into b command input
a > file.txt # save output of command a into file.txt (overwrite)
a >> file.txt # save output of command a into file.txt (append)
echo "Hello!" | xargs echo # injects the output of the first command as an argument of the second command
@gbarreiro
gbarreiro / bash_cheatsheet_change_users.sh
Created December 6, 2020 20:34
Bash cheatsheet: change users
su # change current user to root
su - # change current user and local variables to root
su maria # change current user to "maria"
sudo nano # runs command "nano" as root user
@gbarreiro
gbarreiro / bash_cheatsheet_running_processes.sh
Created December 6, 2020 19:46
Bash cheatsheet: running processes
ps # shows the processes running right now on this terminal session
ps aux # shows all the processes running on the computer
htop # display an activity monitor in the terminal
@gbarreiro
gbarreiro / bash_cheatsheet_system_info.sh
Last active December 7, 2020 21:08
Bash cheatsheet: information about the system
uname -a # shows info about the system (kernel, architecture...)
sudo lshw # (only Linux) list all the hardware components
sudo lshw -short # (only Linux) list a summary table with the hardware components
lscpu # (only Linux) show information about the CPU
lsusb # (only Linux) list the plugged USB devices
date # print the current date and time
@gbarreiro
gbarreiro / bash_cheatsheet_clipboard.sh
Created December 6, 2020 19:05
Bash cheatsheet: clipboard
# Linux
echo "Hello my friend!" | xclip # copy "Hello my friend!" to the clipboard
xclip -o >> pasted_text.txt # paste the content of the clipboard into a text file
# macOS
echo "Hello my friend!" | pbcopy # copy "Hello my friend!" to the clipboard
pbpaste >> pasted_text.txt # paste the content of the clipboard into a text file
@gbarreiro
gbarreiro / bash_cheatsheet_clear.sh
Created December 6, 2020 18:25
Bash cheatsheet: clear the console
clear # cleans the console