본문 바로가기
[개발] Infrastructure/Linux

Ubuntu Server Settings

by Devsong26 2020. 7. 1.

Bitbucket git settings

- ssh key settings

cd ~/.ssh
ssh-keygen -t rsa -C your-email

- create bitbucket config file

vim ~/.ssh/config

# vim mode
Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/id_rsa

- Add ssh key to bitbucket account

1. Copy content ~/.ssh/id_rsa.pub

2. bitbucket account settings > Access keys > Add key > Label: desired name / Key: copy content > add key

 

 

- Go to specific directory and clone your remote project

 

Asia/Seoul Timezone Settings

- sourceLink

- Restart your ubuntu

Configure crontab

login account path global variable: $HOME

code in "crontab -l"

0 5 * * * . $HOME/.profile; /path/shell/script

Crontab is not an interactive shell. Therefore, you must command "$HOME/.profile" in "crontab -e"

The ".bashrc" file does not apply.

 

.bashrc vs .bash_profile

.bash_profile and .bashrc are specific to bash, whereas .profile is read by many shells in the absence of their own shell-specific config files. (.profile was used by the original Bourne shell.) .bash_profile or .profile is read by login shells, along with .bashrc; subshells read only .bashrc. (Between job control and modern windowing systems, .bashrc by itself doesn't get used much. If you use screen or tmux, screens/windows usually run subshells instead of login shells.)

 

The idea behind this was that one-time setup was done by .profile (or shell-specific version thereof), and per-shell stuff by .bashrc. For example, you generally only want to load environment variables once per session instead of getting them whacked any time you launch a subshell within a session, whereas you always want your aliases (which aren't propagated automatically like environment variables are).

 

Other notable shell config files:

 

/etc/bash_profile (fallback /etc/profile) is read before the user's .profile for system-wide configuration, and likewise /etc/bashrc in subshells (no fallback for this one). Many systems including Ubuntu also use an /etc/profile.d directory containing shell scriptlets, which are . (source)-ed from /etc/profile; the fragments here are per-shell, with *.sh applying to all Bourne/POSIX compatible shells and other extensions applying to that particular shell.

 

What is interactive shell?

An interactive shell is simply any shell process that you use to type commands, and get back output from those commands. That is, a shell with which you interact.

 

So, your login shell is interactive, as are any other shells you start manually, as described in the excerpt you quoted in your question. By contrast, when you run a shell script, a non-interactive shell is started that runs the commands in the script, and then exits when the script finishes.

 

The Bourne shell can be used as an interactive shell, just like bash or tcsh. In fact, many systems, such as FreeBSD, use sh as the default user shell. Modern shells like bash, zsh, tcsh, etc have many features that Bourne shell doesn't have, that make them more comfortable and convenient for interactive use (command history, completion, etc).

 

Interactive non-login shells (that is, shells you start manually from another shell or by opening a terminal window) don't read your .login or .profile files. These are only read and executed by login shells (shells started by the login system process, or by your X display manager), so the commands and settings they contain are only applied once, at the beginning of your login session. So, when you start a terminal, the shell that it spawns for you does not read your login files (.login for c-style shells, .profile for bourne style shells), but it does read the .cshrc, .bashrc etc files.

 

Run shell script corresponding to run levels 

There are rc[0-6 or S].d directories in /etc. Each directory has files corresponding to the run levels of the Linux.

 

- Linux Standard Base specification run level information

ID Name Description
0 Halt Shuts down the system.
1 Single-user mode Mode for administrative tasks.
2 Multi-user mode Does not configure network interfaces and does not export networks services.
3 Multi-user mode with networking Starts the system normally.
4 Not used/user-definable For special purposes.
5 Start the system normally with appropriate display manager (with GUI) Same as runlevel 3 + display manager
6 Reboot Reboots the system.

 

Reference Urls

Bitbucket git settings

https://novemberde.github.io/2017/04/18/Bitbucket_access_key_0.html

https://kb.iu.edu/d/bcpe

https://medium.com/@fredrikanderzon/setting-up-ssh-keys-for-multiple-bitbucket-github-accounts-a5244c28c0ac

 

Configure crontab

https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables

https://serverfault.com/questions/261802/what-are-the-functional-differences-between-profile-bash-profile-and-bashrc

https://unix.stackexchange.com/questions/43385/what-do-you-mean-by-interactive-shell

 

Run shell script corresponding to run levels

https://en.wikipedia.org/wiki/Runlevel