Brief
Detail about .bash_profile and .bashrc on CentOS
The differences of .bashrc and .bash_profile
When login to Linux, both $HOME/.bash_profile and $HOME/.bashrc are executed.
When a shell is run, an only .bahsrc is executed.
So if you want to run only when login, write the process to $HOME/.bash_profile
If you want to run every time bash is run, write the process to $HOME/.bashrc
This blog moved to medium->https://medium.com/@cocoamaemae
Regarding TIPS about IT technologies or OSS which I created.
Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts
Wednesday, October 11, 2017
Wednesday, June 14, 2017
How to refurbish tmux
Brief
Surmise how to refurbish tmux
Requirements
OS: CentOS, Ubuntu
How to refurbish
Create $HOME/.tmux.conf
The blow is a sample of .tmux.conf
https://gist.github.com/cocoa-maemae/5e00a4d696d69e7b410d133714771d5d
Debug
If $HOME/.tmux.conf is not reflected, kill a tmux process then run tmux again.
Surmise how to refurbish tmux
Requirements
OS: CentOS, Ubuntu
How to refurbish
Create $HOME/.tmux.conf
The blow is a sample of .tmux.conf
https://gist.github.com/cocoa-maemae/5e00a4d696d69e7b410d133714771d5d
Debug
If $HOME/.tmux.conf is not reflected, kill a tmux process then run tmux again.
e.g.
# Look into a tmux process
ps aux | grep tmux
25718 ? Ss 1:37 tmux
18937 pts/8 S+ 0:00 grep tmux
18937 pts/8 S+ 0:00 grep tmux
# kill a tmux process
kill -9 25718
Tuesday, June 13, 2017
How to use tmux
What is tmux?
Multiple virtual console tools
How to install
(CentOS)
sudo yum install -y tmux
Basic Usage
# Create windows
Ctrl-b,c
# Move to a next window
Ctrl-b,n
# Move to a previous window
Ctrl-b,p
# Divide a pane
Ctrl-b,%
# Move a pane
Ctrl-b,o
Multiple virtual console tools
How to install
(CentOS)
sudo yum install -y tmux
Basic Usage
# Create windows
Ctrl-b,c
# Move to a next window
Ctrl-b,n
# Move to a previous window
Ctrl-b,p
# Divide a pane
Ctrl-b,%
# Move a pane
Ctrl-b,o
Thursday, April 13, 2017
How to add an original yum repository
Add **.repo file under /etc/yum.repos.d/
e.g.
[new-repo] //a repository name
name=nae repository RPM packages // a repository explanation
baseurl=http://new.repository/repo/ // a repository url
gpgcheck=0 // Abbreviate a signature validation
enabled=1 // Abbreviate --enablerepo=***
notice:
Before yum install, "createrepo" execution is on a yum repository server side,
Friday, March 17, 2017
How to use gcc
Basic syntax
-Wall
# Just compile file. not execute linkage
-c
# Just create execute file, link compiled files.
-o <an execute file> <a compiled file> <a compiled file>
# Adds include directory of header files
-I <a directory name>
# Looks in directory for library files
-L <a directory name>
# Links with a library file(.so), however, library name does not include lib.
-l <a library name>
# Display an include target directory
-v <a compile target file>
gcc <options> <file name>
options
# Enables all compiler's warning messages-Wall
# Just compile file. not execute linkage
-c
# Just create execute file, link compiled files.
-o <an execute file> <a compiled file> <a compiled file>
# Adds include directory of header files
-I <a directory name>
# Looks in directory for library files
-L <a directory name>
# Links with a library file(.so), however, library name does not include lib.
-l <a library name>
# Display an include target directory
-v <a compile target file>
Tuesday, February 7, 2017
How to use yum
Basic syntax
yum <options> <package names>
install
# uninstall specified packages
remove
# Search packages which are enable to install
search
# search packages and show which packages are root
whatprovides
# Respond as yes against questions
-y
# Specify a yum configuration file
-c <file path>
yum install <options> <package names>
# Uninstall packages
yum remove <package names>
# Downgrade packages
yum downgrade <package name>
# Display packages installed
yum list installed
# Clear cache
yum clear all
# Install vim and emacs
sudo yum install -y vim emacs
# Uninstall vim and emacs
sudo yum remove vim emacs
yum <options> <package names>
options
# install specified packagesinstall
# uninstall specified packages
remove
# Search packages which are enable to install
search
# search packages and show which packages are root
whatprovides
# Respond as yes against questions
-y
# Specify a yum configuration file
-c <file path>
e.g.
# Install packagesyum install <options> <package names>
# Uninstall packages
yum remove <package names>
# Downgrade packages
yum downgrade <package name>
# Display packages installed
yum list installed
# Clear cache
yum clear all
# Install vim and emacs
sudo yum install -y vim emacs
# Uninstall vim and emacs
sudo yum remove vim emacs
Wednesday, January 18, 2017
How to use supervisor
Brief
Surmise about supervisor
What is Supervisor?
make any modules a daemon
Environment
CentOS
How to install
# add epel repository
sudo yum -y install epel-release
# install
sudo yum -y install supervisor
# start supervisor
sudo systemctl start supervisord
How to configure
# make a module a daemon
sudo supervisorctl start <module name>
Create a configuration file under /etc/supervisor.d/
e.g.
/etc/supervisor.d/xxx.ini
# xxx is a module name which is registered
cat /etc/supervisor.d/xxx.ini
[program:xxx]
command=xxx
user=***
autostart=false
autorestart=true
log_stdout=true
log_stderr=true
redirect_stderr=true
stdout_logfile_maxbytes=**MB
stdout_logfile_backups=**
stdout_logfile=***
Surmise about supervisor
What is Supervisor?
make any modules a daemon
Environment
CentOS
How to install
# add epel repository
sudo yum -y install epel-release
# install
sudo yum -y install supervisor
# start supervisor
sudo systemctl start supervisord
How to configure
# make a module a daemon
sudo supervisorctl start <module name>
Create a configuration file under /etc/supervisor.d/
e.g.
/etc/supervisor.d/xxx.ini
# xxx is a module name which is registered
cat /etc/supervisor.d/xxx.ini
[program:xxx]
command=xxx
user=***
autostart=false
autorestart=true
log_stdout=true
log_stderr=true
redirect_stderr=true
stdout_logfile_maxbytes=**MB
stdout_logfile_backups=**
stdout_logfile=***
Wednesday, January 11, 2017
How to use rpm
Basic syntax
https://gist.github.com/cocoa-maemae/571240f0ea22abe40e203658dc7c28d8
rpm <options> <package name>
options
Moved to Gist.https://gist.github.com/cocoa-maemae/571240f0ea22abe40e203658dc7c28d8
Wednesday, December 14, 2016
How to use du
What's du?
Reports the size of directory trees
Basic syntax
Reports the size of directory trees
Basic syntax
du <options> <file or directory name>
options
# Show capacity
-h
# Show amount of files or directories
-h
# Show amount of files or directories
-s
# Specify tree depth
--max-depth
e.g.
# Specify tree depth
--max-depth
e.g.
# Show capacities from root path tree
du -sh /
du -sh /
Wednesday, November 2, 2016
How to clear cache on CentOS
clear page cache
sudo echo 1 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=1
clear directory entry and inode
sudo echo 2 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=2
clear page cache and directory entry and inode
sudo echo 3 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=3
Monday, October 31, 2016
Linux short cut command cheat sheet
# Go back to the line head
Ctrl+a
# Go to the line end
Ctrl+e
# Remove till end-of-line
Ctrl+k
# Remove characters toward line head by each words
Ctrl+w
# Reset a terminal
Ctrl+l
Ctrl+a
# Go to the line end
Ctrl+e
# Remove till end-of-line
Ctrl+k
# Remove characters toward line head by each words
Ctrl+w
# Reset a terminal
Ctrl+l
Wednesday, September 14, 2016
User management on CentOS
Brief
Surmise about user management on CentOS
See the below regarding basic commands
https://gist.github.com/cocoa-maemae/fd29e2e91d0a75226b09b89e2a367231
# How to add user groups
On centos, add a file under /etc/sudoers.d
e.g.
sudo cat /etc/sudoers.d/hoge
%hoge ALL=(ALL) NOPASSWD: ALL
In this example, the left hoge is a group name.
FYI
If sudo visudo is executed, the following can be seen.
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
includedir is commented out, but this is an unique spec, files under /etc/sudoers.d are loaded automatically.
Surmise about user management on CentOS
See the below regarding basic commands
https://gist.github.com/cocoa-maemae/fd29e2e91d0a75226b09b89e2a367231
# How to add user groups
On centos, add a file under /etc/sudoers.d
e.g.
sudo cat /etc/sudoers.d/hoge
%hoge ALL=(ALL) NOPASSWD: ALL
In this example, the left hoge is a group name.
FYI
If sudo visudo is executed, the following can be seen.
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
includedir is commented out, but this is an unique spec, files under /etc/sudoers.d are loaded automatically.
Tuesday, August 9, 2016
How to use ssh-keygen
Brief
Surmise about ssh-keygen
What is ssh-keygen?
create ssh key pairs, a secret key and a public key
Environment
CentOS
Basic Syntax
ssh-keygen <options>
e.g.
# create a secret key and a public key
# The keys are created in the folder of /root/.ssh/ at the default
ssh-keygen -t 'algorithm name' -m 'comment'
# create a public key from a secret key
ssh-keygen -yf ${private_key_file} > ${public_key_file}
Surmise about ssh-keygen
What is ssh-keygen?
create ssh key pairs, a secret key and a public key
Environment
CentOS
Basic Syntax
ssh-keygen <options>
e.g.
# create a secret key and a public key
# The keys are created in the folder of /root/.ssh/ at the default
ssh-keygen -t 'algorithm name' -m 'comment'
# create a public key from a secret key
ssh-keygen -yf ${private_key_file} > ${public_key_file}
Tuesday, July 26, 2016
Linux file permission
Brief
Surmise about Linux file permission
If you run 'ls -alt', and then the file permission is displayed.
ls -alt
drwxr-xr-x 2 root root 6 Jul 24 14:03 tmp
The status from left means
# File type. d means a direcory.
d
# a file mode of a file owner
rwx
# a file mode of a file group
r-x
# a file mode of another group users
r-x
# the number of link to files
2
# a owner name of a file or a directory
root
# a group name of a file or a directory
root
# used bytes
6
# last updated date
Jul 24 14:03
# a file name or a directory name
tmp
The meanings of r and w and x is like the below.
r: enable to refer
w: enable to change
x: enable to execute
r and w and x are allocated numbers.
r=4
w=2
x=1
Surmise about Linux file permission
If you run 'ls -alt', and then the file permission is displayed.
ls -alt
drwxr-xr-x 2 root root 6 Jul 24 14:03 tmp
The status from left means
# File type. d means a direcory.
d
# a file mode of a file owner
rwx
# a file mode of a file group
r-x
# a file mode of another group users
r-x
# the number of link to files
2
# a owner name of a file or a directory
root
# a group name of a file or a directory
root
# used bytes
6
# last updated date
Jul 24 14:03
# a file name or a directory name
tmp
The meanings of r and w and x is like the below.
r: enable to refer
w: enable to change
x: enable to execute
r and w and x are allocated numbers.
r=4
w=2
x=1
Tuesday, June 21, 2016
How to do ssh login by root on Linux
Brief
It can't be done ssh login by root on Linux default configuration.The below is the solution.
Environment
CentOS[6-7]Procedure
1. Put id_rsa under /root/.ssh/ on a client side and authorized_key under /root/.ssh/ on a server side2. Comment the below portion on /etc/ssh/sshd_config
#PermitRootLogin no
3. Add the below on /etc/ssh/sshd_config
PermitRootLogin without-password
4. Restart sshd
(CentOS7)
sudo systemctl restart sshd
(CentOS6)
sudo service restart sshd
Wednesday, May 18, 2016
How to create or remove symbolic link
What's symbolic link?
Symbolic link is a special kind of link that points to another file.
After created, a link target file is replaced as source file.
How to create symbolic link
e.g.
unlink /usr/bin/ruby
rm /usr/bin/ruby
Symbolic link is a special kind of link that points to another file.
After created, a link target file is replaced as source file.
How to create symbolic link
ln -s <source file name> <link target file name>
e.g.
$ ln -s /usr/local/bin/ruby /usr/bin/ruby
$ ls -alt /usr/bin/ruby
/usr/bin/ruby -> /usr/local/bin/ruby
e.g.
$ ln -s /usr/local/bin/ruby /usr/bin/ruby
$ ls -alt /usr/bin/ruby
/usr/bin/ruby -> /usr/local/bin/ruby
How to remove symbolic link
use unlink or rme.g.
unlink /usr/bin/ruby
rm /usr/bin/ruby
Tuesday, January 5, 2016
Linux ssh management
Brief
Surmise ssh management on Linux
How to create a ssh key pair
execute ssh-keygen command and then $HOME/.ssh directory and $HOME/.ssh/id_rsa and $HOME/.ssh/id_rsa.pub are created automatically by default.
# .ssh folder permission
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/id_rsa
How to add a public key on a ssh server
# add a public key
cat <public key file> >> ~/.ssh/authorized_keys
# change permission
chmod 600 ~/.ssh/authorized_keys
# If from is used, the access origin can be limited
e.g.
from="xxxx.xxxx.xxxx.xxx",no-pty ssh-rsa ***
How to configure ssh authentication
// Modify /etc/ssh/sshd_config and comment out the blow portions.
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFils .ssh/authorized_keys
// To make a password authentication off
PasswordAuthentication no
After modified, restart sshd
Surmise ssh management on Linux
How to create a ssh key pair
execute ssh-keygen command and then $HOME/.ssh directory and $HOME/.ssh/id_rsa and $HOME/.ssh/id_rsa.pub are created automatically by default.
# .ssh folder permission
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/id_rsa
How to add a public key on a ssh server
# add a public key
cat <public key file> >> ~/.ssh/authorized_keys
# change permission
chmod 600 ~/.ssh/authorized_keys
# If from is used, the access origin can be limited
e.g.
from="xxxx.xxxx.xxxx.xxx",no-pty ssh-rsa ***
How to configure ssh authentication
// Modify /etc/ssh/sshd_config and comment out the blow portions.
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFils .ssh/authorized_keys
// To make a password authentication off
PasswordAuthentication no
After modified, restart sshd
Subscribe to:
Posts (Atom)
Front End Development Tools
TaskRunner Tool executing multiple tasks by only one execution. Tasks are like CSS preprocessor, Transpire, Module Bundler, etc... e.g. ...
-
TaskRunner Tool executing multiple tasks by only one execution. Tasks are like CSS preprocessor, Transpire, Module Bundler, etc... e.g. ...
-
Kubernetes words Node Virtual machine or physical server. Cluster It means at least one master node and one node server. Pod It...
-
It is general to create multiple branches and manage them parallel when we do the development by using git. Multiple branches should be mer...