ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • My tweaks after installing Ubuntu
    Development 2021. 7. 26. 15:29
    728x90

    Here is the list of my Linux configuration, after I installed Ubuntu.

    Basic

    As the chapter is basic, I'm going to show my very simple tweaks.

    Remove reverse slash when I type tab key

    • I don't remember since when I have to remove back slash in the front of path, whenever I touch tab key.
    • Add this line in the end of your .bashrc
    • shopt -s direxpand

    Adding user to group

    • Adding skysign to docker group
    • $ sudo usermod -aG docker skysign

    Change directory to the parent of parent directory

    • Just type cd2 in terminal to move the parent of parent directory
    • Believe me, it's very convenient
    $ vim .bash_aliases
    
    Add lines below
    
    alias cd2='cd .. && cd ..'  
    alias cd3='cd .. && cd .. && cd ..'  
    alias cd4='cd .. && cd .. && cd .. && cd ..'  
    alias cd5='cd .. && cd .. && cd .. && cd .. && cd ..'  
    alias cd6='cd .. && cd .. && cd .. && cd .. && cd .. && cd ..'  
    alias cd7='cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd ..'  
    alias cd8='cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd ..'  
    alias cd9='cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd ..'
    

    Advanced, a bit ;)

    Configure timezone

    Especially, Ubuntu in cloud (such as AWS, or Oracle clould), we should set timezone. Please do this before you insert any time record in database, if you are using database.

    
    $ sudo dpkg-reconfigure tzdata
    

    I'll keep update this posting, anything comeup to my mind :-)

    How to use systemctl

    To prevent googling systemctl again ;)

    
    $ sudo systemctl start my-httpd  
    $ sudo systemctl stop my-httpd  
    $ sudo systemctl status my-httpd
    

    Git

    Configure git

    
    My Name  
    $ git config --global user.name "ByeongKeon Kim"
    
    My email  
    $ git config --global user.email [skysign@example.com](mailto:skysign@example.com)
    
    Lastly, use vim as a default editor for git  
    $ git config --global core.editor vim
    

    Generate your ssh key

    Run ssh-keygen and check .ssh folder, there are a pair of your key

    
    ssh-keygen
    

    Adding original repo as upstream

    
    git remote add upstream [https://github.com/ORIGINAL\_OWNER/ORIGINAL\_REPOSITORY.git](https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git)
    
    git fetch upstream
    
    Do PULL REQUEST in github.com
    

    Docker basic

    • How to restart docker?
    • $ sudo service docker restart
    • Show the list of docker containers
    • It shows container id, also
    • $ docker ps -a
    • Launch an image or Create an image from a container
    • We can launch by container id
    • $ docker start <container id>
    • Launch httpd:2.4 with the path of htdocs
    • docker run -dit --name my-httpd -p 80:80 -v "/home/skysign/httpd/www":/usr/local/apache2/htdocs/ httpd:2.4

    Check which ports are opened by using netstat

    • We can see which ports are opend
      netstat -tulpn

    Useful SQL and psql for PostgreSQL

    Example of using psql (PostgreSQL client)

    
    \-h IP  
    \-p port number  
    \-d database name  
    \-U user name  
    psql -h 127.0.0.1 -p 5432 -d trivia -U skysign < trivia.psql
    

    Useful SQL

    • Create user
    
    CREATE USER myuser PASSWORD 'mypassword';
    
    • Let myuser own mydb
    
    CREATE DATABASE mydb OWNER myuser;
    
    • Give all of privileges regarding certain database, to the user
    • GRANT ALL PRIVILEGES ON DATABASE "mydbname" to myusername;

    Virtual Environment

    If multiple project are running in a single server, however, they are requried same lib, but different versions of certain lib.

    • virtualenv is a solution to resolve above

    Create your virtual environment

    python3 -m virtualenv env

    Activate your virtual environment

    source env/bin/activate  
    728x90
Designed by Tistory.