#bash_aliases
Explore tagged Tumblr posts
moonsinkfoxgirl · 10 months ago
Text
in a perfect world I could show a job interviewer my .bash_aliases file with the lines
Tumblr media
in it and they would instantly give me the job
7 notes · View notes
elite-amarys · 1 year ago
Note
case $- in     i) ;;       *) return;; esac
don't put duplicate lines or lines starting with space in the history.
See bash(1) for more options
HISTCONTROL=ignoreboth
append to the history file, don't overwrite it
shopt -s histappend
for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000 HISTFILESIZE=2000
check the window size after each command and, if necessary,
update the values of LINES and COLUMNS.
shopt -s checkwinsize
If set, the pattern "**" used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
shopt -s globstar
make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi
set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in     xterm-color|*-256color) color_prompt=yes;; esac
uncomment for a colored prompt, if the terminal has the capability; turned
off by default to not distract the user: the focus in a terminal window
should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
We have color support; assume it's compliant with Ecma-48
(ISO/IEC-6429). (Lack of such support is extremely rare, and such
a case would tend to support setf rather than setaf.)
color_prompt=yes     else color_prompt=     fi fi
if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt
If this is an xterm set the title to user@host:dir
case "$TERM" in xterm|rxvt)     PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"     ;; *)     ;; esac
enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"     alias ls='ls --color=auto'     #alias dir='dir --color=auto'     #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'     alias fgrep='fgrep --color=auto'     alias egrep='egrep --color=auto' fi
colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
some more ls aliases
alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Add an "alert" alias for long running commands.  Use like so:
  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'
Alias definitions.
You may want to put all your additions into a separate file like
~/.bash_aliases, instead of adding them here directly.
See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if ! shopt -oq posix; then   if [ -f /usr/share/bash-completion/bash_completion ]; then     . /usr/share/bash-completion/bash_completion   elif [ -f /etc/bash_completion ]; then     . /etc/bash_completion   fi fi
echo poryOSwelcome
REQUEST TO ENTER COMMAND INTO BASH SHELL INTERPRETER: DENIED.
ALTERNATIVE COMMAND:
DROP TABLE IF EXISTS: YOUR LIFE.
2 notes · View notes
faller-of-kharbranth · 1 year ago
Note
case $- in     i) ;;       *) return;; esac
don't put duplicate lines or lines starting with space in the history.
See bash(1) for more options
HISTCONTROL=ignoreboth
append to the history file, don't overwrite it
shopt -s histappend
for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000 HISTFILESIZE=2000
check the window size after each command and, if necessary,
update the values of LINES and COLUMNS.
shopt -s checkwinsize
If set, the pattern "**" used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
shopt -s globstar
make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi
set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in     xterm-color|*-256color) color_prompt=yes;; esac
uncomment for a colored prompt, if the terminal has the capability; turned
off by default to not distract the user: the focus in a terminal window
should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
We have color support; assume it's compliant with Ecma-48
(ISO/IEC-6429). (Lack of such support is extremely rare, and such
a case would tend to support setf rather than setaf.)
color_prompt=yes     else color_prompt=     fi fi
if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt
If this is an xterm set the title to user@host:dir
case "$TERM" in xterm|rxvt)     PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"     ;; *)     ;; esac
enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"     alias ls='ls --color=auto'     #alias dir='dir --color=auto'     #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'     alias fgrep='fgrep --color=auto'     alias egrep='egrep --color=auto' fi
colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
some more ls aliases
alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Add an "alert" alias for long running commands.  Use like so:
  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'
Alias definitions.
You may want to put all your additions into a separate file like
~/.bash_aliases, instead of adding them here directly.
See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if ! shopt -oq posix; then   if [ -f /usr/share/bash-completion/bash_completion ]; then     . /usr/share/bash-completion/bash_completion   elif [ -f /etc/bash_completion ]; then     . /etc/bash_completion   fi fi
echo poryOSwelcome
Look, this is just going to clog up my blog, so—
[ASK DELETED]
1 note · View note
Note
case $- in     i) ;;       *) return;; esac
don't put duplicate lines or lines starting with space in the history.
See bash(1) for more options
HISTCONTROL=ignoreboth
append to the history file, don't overwrite it
shopt -s histappend
for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000 HISTFILESIZE=2000
check the window size after each command and, if necessary,
update the values of LINES and COLUMNS.
shopt -s checkwinsize
If set, the pattern "**" used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
shopt -s globstar
make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi
set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in     xterm-color|*-256color) color_prompt=yes;; esac
uncomment for a colored prompt, if the terminal has the capability; turned
off by default to not distract the user: the focus in a terminal window
should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
We have color support; assume it's compliant with Ecma-48
(ISO/IEC-6429). (Lack of such support is extremely rare, and such
a case would tend to support setf rather than setaf.)
color_prompt=yes     else color_prompt=     fi fi
if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt
If this is an xterm set the title to user@host:dir
case "$TERM" in xterm|rxvt)     PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"     ;; *)     ;; esac
enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"     alias ls='ls --color=auto'     #alias dir='dir --color=auto'     #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'     alias fgrep='fgrep --color=auto'     alias egrep='egrep --color=auto' fi
colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
some more ls aliases
alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Add an "alert" alias for long running commands.  Use like so:
  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'
Alias definitions.
You may want to put all your additions into a separate file like
~/.bash_aliases, instead of adding them here directly.
See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if ! shopt -oq posix; then   if [ -f /usr/share/bash-completion/bash_completion ]; then     . /usr/share/bash-completion/bash_completion   elif [ -f /etc/bash_completion ]; then     . /etc/bash_completion   fi fi
echo poryOSwelcome
Another, error?
1 note · View note
aura-acolyte · 1 year ago
Note
case $- in     i) ;;       *) return;; esac
don't put duplicate lines or lines starting with space in the history.
See bash(1) for more options
HISTCONTROL=ignoreboth
append to the history file, don't overwrite it
shopt -s histappend
for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000 HISTFILESIZE=2000
check the window size after each command and, if necessary,
update the values of LINES and COLUMNS.
shopt -s checkwinsize
If set, the pattern "**" used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
shopt -s globstar
make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi
set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in     xterm-color|*-256color) color_prompt=yes;; esac
uncomment for a colored prompt, if the terminal has the capability; turned
off by default to not distract the user: the focus in a terminal window
should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
We have color support; assume it's compliant with Ecma-48
(ISO/IEC-6429). (Lack of such support is extremely rare, and such
a case would tend to support setf rather than setaf.)
color_prompt=yes     else color_prompt=     fi fi
if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt
If this is an xterm set the title to user@host:dir
case "$TERM" in xterm|rxvt)     PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"     ;; *)     ;; esac
enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"     alias ls='ls --color=auto'     #alias dir='dir --color=auto'     #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'     alias fgrep='fgrep --color=auto'     alias egrep='egrep --color=auto' fi
colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
some more ls aliases
alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Add an "alert" alias for long running commands.  Use like so:
  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'
Alias definitions.
You may want to put all your additions into a separate file like
~/.bash_aliases, instead of adding them here directly.
See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if ! shopt -oq posix; then   if [ -f /usr/share/bash-completion/bash_completion ]; then     . /usr/share/bash-completion/bash_completion   elif [ -f /etc/bash_completion ]; then     . /etc/bash_completion   fi fi
echo poryOSwelcome
Um... hi?
0 notes
admin-courtneys-corner · 1 year ago
Note
case $- in     i) ;;       *) return;; esac
don't put duplicate lines or lines starting with space in the history.
See bash(1) for more options
HISTCONTROL=ignoreboth
append to the history file, don't overwrite it
shopt -s histappend
for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000 HISTFILESIZE=2000
check the window size after each command and, if necessary,
update the values of LINES and COLUMNS.
shopt -s checkwinsize
If set, the pattern "**" used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
shopt -s globstar
make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi
set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in     xterm-color|*-256color) color_prompt=yes;; esac
uncomment for a colored prompt, if the terminal has the capability; turned
off by default to not distract the user: the focus in a terminal window
should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
We have color support; assume it's compliant with Ecma-48
(ISO/IEC-6429). (Lack of such support is extremely rare, and such
a case would tend to support setf rather than setaf.)
color_prompt=yes     else color_prompt=     fi fi
if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt
If this is an xterm set the title to user@host:dir
case "$TERM" in xterm|rxvt)     PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"     ;; *)     ;; esac
enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"     alias ls='ls --color=auto'     #alias dir='dir --color=auto'     #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'     alias fgrep='fgrep --color=auto'     alias egrep='egrep --color=auto' fi
colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
some more ls aliases
alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Add an "alert" alias for long running commands.  Use like so:
  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'
Alias definitions.
You may want to put all your additions into a separate file like
~/.bash_aliases, instead of adding them here directly.
See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if ! shopt -oq posix; then   if [ -f /usr/share/bash-completion/bash_completion ]; then     . /usr/share/bash-completion/bash_completion   elif [ -f /etc/bash_completion ]; then     . /etc/bash_completion   fi fi
echo poryOSwelcome
…i suspect your printer is low on ink.
1 note · View note
realfakekraid · 6 years ago
Text
Who has two declaws and just spent way too much time setting up a personal wiki on a raspberry pi?
Tumblr media
This Kraid!
<venting mode>
If someone told you that setting up a wiki was easy, someone lied.
Like goddamn, I spent 2 hours trying solve a login problem that, from what I can tell, can be caused by approximately 17 different things. My version of the problem was fixed by changing CACHE_ACCEL to CACHE_ANYTHING in localsettings.php. There's like 16 other ways of fixing that problem, and none of them seem to be related to one another. I HAD TO LEARN SQL SHIT! AND NOTHING I LEARNED THERE FIXED ANYTHING! NOT A GODDAMN THING!
Anyway....
I can't even remember why I wanted to set this thing up now. I think I was going to use it for note taking, or something?
I would like to give a huge, huge thanks to whomever cooked up ssh back in the day. No sarcasm, being able to control my pi from a terminal emulator on my laptop turns out to be INSANELY useful!
Also a huge thanks to whomever did the scp command, also hella useful for getting files from the laptop to the pi and vise versa without having to set up ftp servers or shutting down the pi and ripping the msd card out every time.
Like, seriously though, fuck SQL. And it wasn't even the thing causing the problem, it was just that God awful an experience. Well, one of the problems. There was the chmod thing. And the learning curve of Apache on Debian - I learned a little bit about a decade ago on Windows and it tripped me up a little, but that's on me.
And god bless Linux's ability to create aliases. So much repetitive typing saved by that simple ability.
Alias realias="source ~/.bashrc"
Alias restart="sudo systemctl restart apache2"
Alias nanowiki="sudo nano /path/to/LocalSettings.php"
</venting mode>
Is it possible to, I dunno, set up a router to translate certain urls into internal ip addresses? Like how some of those wifi extenders can do for accessing their setup server. Like resolve http://something.here into 192.169.x.y instead of hitting up an external DNS server?
1 note · View note
mattn · 5 years ago
Text
WSL2 でクリップボード使いたい。
WSL2 がリリースされ Windows 10 Home Edition でも使える様になったので色々遊んでるのだけど、Windows 側とテキストを交換したい時に面倒で、クリップボードを共有する方法を模索した。
最悪 /dev/clipboard を実装するまで考えたけど、面倒過ぎたし exe の実行厳しい(何か常駐させてユーザランドから起動する為にサーバがいる)だろうから別の方法を考えた。WSL2 は binfmt (たぶん違うけど良く似た奴だろう) で Windows の exe が起動できるので、コマンド経由で stdin/stdout を read/write できる物を起動する方法を考えた。
で自分で書くかと Windows Terminal 起動した時点で「Windows Terminal からコピペできるやん、いらなくね?」となり、本来の目的を忘れかけていたので、おとなしく GitHub からそういったコマンドを探した。
GitHub - equalsraf/win32yank: Windows clipboard tool
Dismiss Join GitHub today GitHub is home to over 50 million developers working together to host and ...
https://ift.tt/2sABUDu
こちら便利そうだったけど、僕は Go 言語使いなので、go get で一発で入るのが欲しかった。最終的には以下のリポジトリにある gocopy と gopaste が良さそうだった。
GitHub - atotto/clipboard: clipboard for golang
Clipboard for Go Provide copying and pasting to the Clipboard for Go. Build: -1 go get github.com/ato...
https://ift.tt/1A1iEI7
Windows 側では以下の様にインストールする。
go get github.com/atotto/clipboard/cmd/gocopy go get github.com/atotto/clipboard/cmd/gopate
あとは WSL2 の .bash_aliases に以下を足した。
alias gocopy=/mnt/c/Users/mattn/go/bin/gocopy.exe alias gopaste=/mnt/c/Users/mattn/go/bin/gopaste.exe
パスは個人によって違うの修正して下さい。
$ echo あいう | gocopy $ gopaste あいう
こんな感じに使う。
追記
Vim から :w !goclip したいのであれば alias じゃなく shell で wrapper 書くかシンボリックリンクを WSL2 のパスの通った所に張るのが良さそうです。ちなみに PowerShell の get-clipboard と clip.exe でも出来るけど遅いのが嫌いなのでこの方法にしました。
from Big Sky https://ift.tt/36RgTVO
2 notes · View notes
chaincubelog · 8 years ago
Text
aliasの作成, 確認, 削除
端末上でエイリアスをタブキーで補完していたら、消したと思っていた古いエイリアスがそのまま残ってたりして気持ち悪かったのでちゃんとしておいたメモ。 環境はUbuntu/Debian上のbash.
■ 新しくaliasを作って登録 例えばlsコマンドを自分好みにして登録する場合は以下のように alias lll='ls -alF --time-style=+%Y%m%d-%H%M-%S' と書き、~/.bashrcの適当な箇所へ追記。
書き込んで保存したらbashを更新して反映。 $ source ~/.bashrc
また、.bashrcの行数が多く混雑してしまうのが嫌なので外部に隔てるとき
if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi と.bashrcに書いておいて別個、同じディレクトリ内へ.bash_aliasesというファイルを作って連結する方法があり、この場合も更新はsourceでok. Ubuntuではデフォルトで既に書かれていてコメントアウトされている。
■ aliasの一覧を確認 $ alias
■ aliasの削除 $ unalias aliasname unaliasの引数-aを付けると全削除。
■ コメントの利用 行頭に#からでおk
3 notes · View notes
leagq · 6 years ago
Text
Master the Linux 'ls' command
Master the Linux 'ls' command https://red.ht/2YfHYfe
Tumblr media
The ls command lists files on a POSIX system. It's a simple command, often underestimated, not in what it can do (because it really does only one thing), but in how you can optimize your use of it.
Of the 10 most essential terminal commands to know, the humble ls command is in the top three, because ls doesn't just list files, it tells you important information about them. It tells you things like who owns a file or directory, when each file was lost or modified, and even what kind of file it is. And then there's its incidental function of giving you a sense of where you are, what nearby objects are lying around, and what you can do with them.
If your experience with ls is limited to whatever your distribution aliases it to in .bashrc, then you're probably missing out.
GNU or BSD?
Before looking at the hidden powers of ls, you must determine which ls command you're running. The two most popular versions are the GNU version, included in the GNU coreutils package, and the BSD version. If you're running Linux, then you probably have ls installed. If you're running BSD or MacOS, then you have the BSD version. There are differences, for which this article accounts.
You can find out which version is on your computer with the --version option:
$ ls --version
If this returns information about GNU coreutils, then you have the GNU version. If it returns an error, you're probably running the BSD version (run man ls | head to be sure).
You should also investigate what presets your distribution may have in place. Customizations to terminal commands are frequently placed in $HOME/.bashrc or $HOME/.bash_aliases or $HOME/.profile, and they're accomplished by aliasing ls to a more complex ls command. For example:
alias ls='ls --color'
The presets provided by distributions are very helpful, but they do make it difficult to discern what ls does on its own and what its additional options provide. Should you ever want to run ls and not the alias, you can "escape" the command with a backslash:
$ \ls
Classify
Run on its own, ls simply lists files in as many columns as can fit into your terminal:
$ ls ~/example bunko        jdk-10.0.2 chapterize   otf2ttf.ff despacer     overtar.sh estimate.sh  pandoc-2.7.1 fop-2.3      safe_yaml games        tt
It's useful information, but all of those files look basically the same without the convenience of icons to quickly convey which is a directory, or a text file, or an image, and so on.
Use the -F (or --classify on GNU) to show indicators after each entry that identify the kind of file it is:
$ ls ~/example bunko         jdk-10.0.2/ chapterize*   otf2ttf.ff* despacer*     overtar.sh* estimate.sh   pandoc@ fop-2.3/      pandoc-2.7.1/ games/        tt*
With this option, items listed in your terminal are classified by file type using this shorthand:
A slash (/) denotes a directory (or "folder").
An asterisk (*) denotes an executable file. This includes a binary file (compiled code) as well as scripts (text files that have executable permission).
An at sign (@) denotes a symbolic link (or "alias").
An equals sign (=) denotes a socket.
On BSD, a percent sign (%) denotes a whiteout (a method of file removal on certain file systems).
On GNU, an angle bracket (>) denotes a door (inter-process communication on Illumos and Solaris).
A vertical bar (|) denotes a FIFO.
A simpler version of this option is -p, which only differentiates a file from a directory.
Long list
Getting a "long list" from ls is so common that many distributions alias ll to ls -l. The long list form provides many important file attributes, such as permissions, the user who owns each file, the group to which the file belongs, the file size in bytes, and the date the file was last changed:
$ ls -l -rwxrwx---. 1 seth users         455 Mar  2  2017 estimate.sh -rwxrwxr-x. 1 seth users         662 Apr 29 22:27 factorial -rwxrwx---. 1 seth users    20697793 Jun 29  2018 fop-2.3-bin.tar.gz -rwxrwxr-x. 1 seth users        6210 May 22 10:22 geteltorito -rwxrwx---. 1 seth users         177 Nov 12  2018 html4mutt.sh [...]
If you don't think in bytes, add the -h flag (or --human in GNU) to translate file sizes to more human-friendly notation:
$ ls --human -rwxrwx---. 1 seth users    455 Mar  2  2017 estimate.sh -rwxrwxr-x. 1 seth seth     662 Apr 29 22:27 factorial -rwxrwx---. 1 seth users    20M Jun 29  2018 fop-2.3-bin.tar.gz -rwxrwxr-x. 1 seth seth    6.1K May 22 10:22 geteltorito -rwxrwx---. 1 seth users    177 Nov 12  2018 html4mutt.sh
You can see just a little less information by showing only the owner column with -o or only the group column with -g:
$ ls -o -rwxrwx---. 1 seth    455 Mar  2  2017 estimate.sh -rwxrwxr-x. 1 seth    662 Apr 29 22:27 factorial -rwxrwx---. 1 seth    20M Jun 29  2018 fop-2.3-bin.tar.gz -rwxrwxr-x. 1 seth   6.1K May 22 10:22 geteltorito -rwxrwx---. 1 seth    177 Nov 12  2018 html4mutt.sh
Combine both options to show neither.
Time and date format
The long list format of ls usually looks like this:
-rwxrwx---. 1 seth users         455 Mar  2  2017 estimate.sh -rwxrwxr-x. 1 seth users         662 Apr 29 22:27 factorial -rwxrwx---. 1 seth users    20697793 Jun 29  2018 fop-2.3-bin.tar.gz -rwxrwxr-x. 1 seth users        6210 May 22 10:22 geteltorito -rwxrwx---. 1 seth users         177 Nov 12  2018 html4mutt.sh
The names of months aren't easy to sort, both computationally or (depending on whether your brain tends to prefer strings or integers) by recognition. You can change the format of the time stamp with the --time-style option plus the name of a format. Available formats are:
full-iso (1970-01-01 21:12:00)
long-iso (1970-01-01 21:12)
iso (01-01 21:12)
locale (uses your locale settings)
posix-STYLE (replace STYLE with a locale definition)
You can also create a custom style using the formal notation of the date command.
Sort by time
Usually, the ls command sorts alphabetically. You can make it sort according to which file was most recently changed (the newest is listed first) with the -t option.
For example:
$ touch foo bar baz $ ls bar  baz  foo $ touch foo $ ls -t foo bar baz
List type
The standard output of ls balances readability with space efficiency, but sometimes you want your file list in a specific arrangement.
For a comma-separated list of files, use -m:
ls -m ~/example bar, baz, foo
To force one file per line, use the -1 option (that's the number one, not a lowercase L):
$ ls -1 ~/bin/ bar baz foo
To sort entries by file extension rather than the filename, use -X (that's a capital X):
$ ls bar.xfc  baz.txt  foo.asc $ ls -X foo.asc  baz.txt  bar.xfc
Hide the clutter
There are a few entries in some ls listings that you may not care about. For instance, the metacharacters . and .. represent "here" and "back one level," respectively. If you're familiar with navigating in a terminal, you probably already know that each directory refers to itself as . and to its parent as .., so you don't need to be constantly reminded of it when you use the -a option to show hidden files.
To show almost all hidden files (the . and .. excluded), use the -A option:
$ ls -a . .. .android .atom .bash_aliases [...] $ ls -A .android .atom .bash_aliases [...]
With many good Unix tools, there's a tradition of saving backup files by appending some special character to the name of the file being saved. For instance, in Vim, backups get saved with the ~ character appended to the name.
These kinds of backup files have saved me from stupid mistakes on several occasions, but after years of enjoying the sense of security they provide, I don't feel the need to have visual evidence that they exist. I trust Linux applications to generate backup files (if they claim to do so), and I'm happy to take it on faith that they exist.
To hide backup files from view, use -B or --ignore-backups to conceal common backup formats (this option is not available in BSD ls):
$ ls bar.xfc  baz.txt  foo.asc~  foo.asc $ ls -B bar.xfc  baz.txt  foo.asc
Of course, the backup file still exists; it's just filtered out so that you don't have to look at it.
GNU Emacs saves backup files (unless otherwise configured) with a hash character (#) at the start and end of the file name (#file#). Other applications may use a different style. It doesn't matter what pattern is used, because you can create your own exclusions with the --hide option:
$ ls bar.xfc  baz.txt  #foo.asc#  foo.asc $ ls --hide="#*#" bar.xfc  baz.txt  foo.asc
List directories with recursion
The contents of directories are not listed with the ls command unless you run ls on that directory specifically:
$ ls -F example/  quux*  xyz.txt $ ls -R quux  xyz.txt ./example: bar.xfc  baz.txt  #foo.asc#  foo.asc
Make it permanent with an alias
The ls command is probably the command used most often during any given shell session. It's your eyes and ears, providing you with context and confirming the results of commands. While it's useful to have lots of options, part of the beauty of ls is its brevity: two characters and the Return key, and you know exactly where you are and what's nearby. If you have to stop to think about (much less type) several different options, it becomes less convenient, so typically even the most useful options are left off.
The solution is to alias your ls command so that when you use it, you get the information you care about the most.
To create an alias for a command in the Bash shell, create a file in your home directory called .bash_aliases (you must include the dot at the beginning). In this file, list the command you want to create an alias for and then the alias you want to create. For example:
alias ls='ls -A -F -B --human --color'
This line causes your Bash shell to interpret the ls command as ls -A -F -B --human --color.
You aren't limited to redefining existing commands. You can create your own aliases:
alias ll='ls -l' alias la='ls -A' alias lh='ls -h'
For aliases to work, your shell must know that the .bash_aliases configuration file exists. Open the .bashrc file in an editor (or create it, if it doesn't exist), and include this block of code:
if [ -e $HOME/.bash_aliases ]; then     source $HOME/.bash_aliases fi
Each time .bashrc is loaded (which is any time a new Bash shell is launched), Bash will load .bash_aliases into your environment. You can close and relaunch your Bash session or just force it to do that now:
$ source ~/.bashrc
If you forget whether you have aliased a command, the which command tells you:
$ which ls alias ls='ls -A -F -B --human --color'         /usr/bin/ls
If you've aliased the ls command to itself with options, you can override your own alias at any time by prefacing ls with a backslash. For instance, in the example alias, backup files are hidden using the -B option, which means there's no way to back up files with the ls command. Override the alias to see the backup files:
$ ls bar  baz  foo $ \ls bar  baz  baz~  foo
Do one thing and do it well
The ls command has a staggering number of options, many of which are niche or highly dependent upon the terminal you use. Take a look at info ls on GNU systems or man ls on GNU or BSD systems for more options.
You might find it strange that a system famous for the premise that each tool "does one thing and does it well" would weigh down its most common command with 50 options. But ls does only one thing: it lists files. And with 50 options to allow you to control how you receive that list, ls does its one job very, very well.
via Opensource.com https://red.ht/2JQVGBt https://red.ht/2JO4xDK July 24, 2019 at 04:14AM
0 notes
thetechnologyguy-blog1 · 6 years ago
Text
VULNERABILIDADES CON MÁS DE 30 AÑOS DE ANTIGÜEDAD EN SCP
Tumblr media
Estas fallas podrían conducir a ejecución de comandos remotos en los sistemas comprometidos
Acorde a expertos en seguridad en redes del Instituto Internacional de Seguridad Cibernética, ha sido descubierto un conjunto de vulnerabilidades de 36 años de antigüedad en la implementación del Protocolo de Copia Segura (SCP) de múltiples aplicaciones de clientes; las vulnerabilidades podrían ser explotadas por usuarios maliciosos para sobrescribir archivos de forma arbitraria en el directorio de destino del cliente de SCP sin autorización.
El SCP (también conocido como Protocolo de Control de Sesión) es un protocolo de red que permite a los usuarios transferir archivos de forma segura entre un host local y uno remoto mediante el Protocolo de Copia Remota (RCP) y el protocolo SSH.
Dicho de otro modo, el protocolo SCP, creado en 1983, es una versión segura de RCP que requiere de la autenticación y el cifrado del protocolo SSH para transferir archivos entre el servidor y el cliente, mencionan expertos en seguridad en redes.
Las vulnerabilidades, descubiertas por el experto en ciberseguridad Harry Sintonen, existen debido a las deficientes validaciones realizadas por los clientes de SCP, que podrían ser explotadas por servidores maliciosos o utilizando alguna variante del ataque Man-in-the-Middle (MiTM) para eliminar o sobrescribir archivos arbitrarios en el sistema de los clientes.
“Muchos clientes SCP no verifican si los objetos devueltos por el servidor SCP coinciden con las solicitudes. Este problema se remonta al año 1983 y al protocolo RCP, en el que está basado SCP”, mencionó el experto.
Un servidor controlado por un atacante podría colocar un archivo .bash_aliases en el directorio de inicio de la víctima, engañando al sistema para que ejecute comandos maliciosos tan pronto como el usuario de Linux inicie un nuevo shell.
Múltiples vulnerabilidades
Según el reporte, las vulnerabilidades fueron descubiertas y reportadas a los desarrolladores posiblemente comprometidos en agosto del año pasado. La lista de vulnerabilidades incluye:
Validación incorrecta del nombre de directorio del cliente SCP (CVE-2018-20685)
El cliente SCP no recibió la validación del nombre del objeto recibido (CVE-2019-6111)
Falsificación del cliente SCP a través del nombre del objeto (CVE-2019-6109)
Suplantación de cliente SCP mediante stderr (CVE-2019-6110)
Dado que las vulnerabilidades afectan la implementación del protocolo SCP, todas las aplicaciones cliente de SCP, incluidas OpenSSH, PuTTY y WinSCP, utilizan SCP como estándar para transferir archivos. WinSCP solucionó los problemas con el lanzamiento de la versión 5.14 en octubre pasado, y el parche también se incluye en la versión actual 5.14.4.
La vulnerabilidad CVE-2018-20685 fue corregida en la implementación del protocolo SCP en noviembre pasado, aunque la corrección no ha sido publicada oficialmente por los proveedores. Las otras tres vulnerabilidades permanecen sin ser corregidas.
Sin embargo, si está preocupado de que un servidor SCP malintencionado le haya atacado, puede configurar sus sistemas para que utilicen SFTP (FTP seguro) si es posible. Como alternativa, el experto en seguridad en redes también proporcionó una solución para reforzar SCP contra la mayoría de los intentos de manipulación del lado del servidor, que puede aplicar directamente, aunque puede causar algunos problemas.
Se recomienda a los usuarios posiblemente afectados mantenerse a la expectativa del lanzamiento de los parches de seguridad, así como aplicarlos en sus sistemas tan pronto como estén disponibles.
0 notes
belleandkurtbastian · 5 years ago
Text
... I just found this in my ~/.bash_aliases pic.twitter.com/ChBbenVV7W
— Andrew Marsden🏳️‍🌈 💛🤍💜🖤 (@marsdeat) May 13, 2020
0 notes
kirito-1011 · 5 years ago
Text
System-wide aliases
[ad_1]
I have my aliases set in my ~/.bash_aliases, it works like a charm in terminal. Howerver, it doesn't do the same with Application Finder (Alt + F2) or Whisker Menu. Anybody know how to fix this? Thanks.
submitted by /u/huysmithz [comments] [ad_2]
View On WordPress
0 notes
thehowtostuff-blog · 6 years ago
Link
It’s small, it’s powerful, and it can do almost anything. But the Raspberry Pi hasn’t been great for gaming… until now.
After retiring the Steam Link hardware, Valve has released Steam Link software for Raspberry Pi. Streaming games from PC to Raspberry Pi is now official, using a dedicated app and without relying on Moonlight.
What is great about this is that you can set it up in just a few minutes. Now you can install Steam Link software on your Raspberry Pi to play games running on your PC. Here’s everything you need to know.
What You Need to Play Steam Games on Raspberry Pi
Previously you could install Nvidia GeForce on your PC (if compatible) and use the open source implementation of Nvidia’s GameStream software (Moonlight) to stream games via your Raspberry Pi.
Now all you need to stream games from Steam to your Raspberry Pi is:
A Raspberry Pi 3B or 3B+
8GB or great microSD card with Raspbian Stretch installed
Keyboard and mouse
A suitable game controller (see below)
A router with Ethernet ports (5GHz wireless is not recommended for the Raspberry Pi)
Two Ethernet cables.
HDMI cable
A suitable TV for gaming
Steam software on your computer, a Steam account and library of games
You will also need a computer running Steam on Windows 7 or later, Mac OS X 10.10 Yosemite or later, or Linux Ubuntu 12.04 or newer. You should have an account with Steam and at least one game installed.
If you’re new to the Raspberry Pi, you’ll need a copy of the Debian-based Raspbian Stretch operating system. Get started with our guide to installing an operating system on the Raspberry Pi.
Configure Your PC for Steam In-Home Streaming
Boot your PC and connect it to your home network via Ethernet. This is necessary as forcing the Raspberry Pi to rely on its wireless radio adds to its processing load.
By comparison, the Steam Link hardware from Valve gave better results when connected via Ethernet. As Ethernet is faster than Wi-Fi, it makes sense to use it for the best performance. (You can use the Pi-powered Steam Link over Wi-Fi, but it should be as close as possible to the router.)
Steam should be installed on your PC, running, and up-to-date.
Updates usually occur automatically when you launch Steam, but if this doesn’t happen, open the Steam menu and select Check for Steam Client Updates.
Once updated, go to View > Settings and select In-Home Streaming. Here, check Enable streaming and ensure the Client options button is set to Balanced. (You might change this later to improve performance.)
Click OK to confirm.
How to Install Steam Link on the Raspberry Pi
Like your computer, the Raspberry Pi should be connected to your network via Ethernet. Once booted up, open the Terminal window (use the Ctrl + Alt + T shortcut) and enter:
sudo apt update sudo apt install steamlink
The first of these commands updates the Raspberry Pi’s packages list. Meanwhile the second finds the Steam Link software in the packages and installs it.
Wait while the process completes, hitting Y to confirm if prompted.
A few moments later the Steam Link software will be installed on your Raspberry Pi. Assuming you have games in your Steam library, you’re ready to start playing on your TV, via the Raspberry Pi.
Run Steam Link and Play Games on Your TV
To launch the Steam Link software, open Menu > Games > Steam Link on your Raspberry Pi.
A full screen Steam interface will appear, displaying the name of your computer and the attached controller. Select your computer to start the network test. You’ll be prompted by Steam Link on the Raspberry Pi to enter a PIN code on your computer, so do this and click OK.
If all goes well, you should see a message informing you that the network will work with Steam Link. Use OK and Back to return to the main menu.
You may, however, be notified of the need to update your drivers. Steam will handle this for you, simply click Install when prompted.
Once this is updated, you’ll be able to access your Steam library. Note that the software will be running in the foreground on your PC (as opposed to a background process) so be sure no one plans to use the computer while you’re gaming.
When you’re all done, hit the power button in Steam and click Stop Streaming.
How to Connect a Game Controller to Raspberry Pi Steam Link
Use the following game controllers with Steam Link:
Steam Controller
Xbox One wired
Xbox 360 wireless or wired
Sony Dualshock 4 wireless or wired
Nintendo Switch Pro
For USB controllers, all you need to do is plug and play. For Bluetooth, however, you’ll need to enable it via the Raspbian desktop.
Click on the Bluetooth icon in the menu bar and Turn on Bluetooth. Next, click Bluetooth again and Add Device.
Put the game controller in pairing mode (check the device’s documentation for details), then wait as the device is detected. Select it, click Pair, and follow any instructions to complete the pairing.
Note that you may need to repeat the process a few times to get it to work.
Boot Your Raspberry Pi Directly Into Steam Link
Want to use your Raspberry Pi 3 or later as a dedicated Steam Link? Easy!
In the Terminal window, enter
sudo nano .bash_aliases
In the blank file, input:
steamlink
Hit Ctrl + X then Y to save and exit nano, and restart the Raspberry Pi:
sudo shutdown -r now
or
sudo reboot
When the Pi restarts, it will now boot straight into the Steam Link software.
You’re ready to play!
Troubleshooting the Raspberry Pi Steam Link
Getting the Steam Link software set up with the Raspberry Pi is straightforward. But it might not quite work right for you. Fortunately, some simple troubleshooting can fix most issues.
Unresponsive or choppy gameplay? Switch to a wired Ethernet connection instead of wireless networking.
Entered PIN but no connection? Try upgrading your graphics device drivers. If your system uses Nvidia drivers, update GeForce Experience, then try again.
Can’t connect your Bluetooth controller? Shut down any console the controller is usually paired with.
General poor performance? Check our tips to optimize your Raspberry Pi, focusing specifically on the power supply and a new microSD card.
How to Stream Steam on Raspberry Pi Using Moonlight
If for some reason the official Steam Link software doesn’t work but you still want to stream games to your Raspberry Pi, some alternatives are available.
Most notable is Moonlight, as mentioned above. This requires your PC to have a GTX 650 or higher Nvidia GPU and the GeForce Experience software. Before proceeding, you should update both Steam and GeForce Experience.
When you’re ready, install these dependencies in Raspbian Stretch:
sudo apt install libopus0 libasound2 libudev0 libavahi-client3 libcurl3 libevdev2
Next, edit the sources list:
sudo nano /etc/apt/sources.list
In the text editor, add:
deb http://archive.itimmer.nl/raspbian/moonlight stretch main
Press Ctrl + X to save (confirm with Y) then download and add the GPG key.
wget http://archive.itimmer.nl/itimmer.gpg sudo apt-key add itimmer.gpg
Update your sources:
sudo apt update
Then install Moonlight:
sudo apt install moonlight-embedded
You can then pair the Pi with the PC. Check the PC’s IP address (ipconfig in the Windows command line, ifconfig on Linux) then enter
moonlight pair [ip address]
Look for the Nvidia GeForce Experience popup on your PC and enter the PIN number when prompted.
Ready to play a game? Enter the following:
moonlight stream [options] -app [app name]
Where [options] is something like the resolution and FPS (-1080 -30fps for example) and the [app name] the name of the game.
Note: It’s worth noting that Moonlight is likely to fall out of favor with the arrival of the Steam Link software. If it doesn’t work for you right now, updates from Valve might well resolve any issues you’re facing.
Want to stream other games from your PC to your TV? Our guide to Parsec will help you stream any game from PC to Raspberry Pi.
More Ways to Play Games on Raspberry Pi
If you’ve followed the steps and used the right hardware, you should now be able to stream PC games across your network via your Raspberry Pi.
Steam Link isn’t limited to streaming games to your TV, either. The software is available on mobile devices, enabling you to play PC games on Android.
Enjoyed playing your favorite PC games on your Raspberry Pi? It’s just the beginning. Thanks to streaming and emulation, a huge number of games can be played on the Raspberry Pi.
Read the full article: How to Stream Steam Games to Raspberry Pi Without Moonlight
from MakeUseOf https://ift.tt/2EjcuNv
0 notes
awsexchage · 7 years ago
Photo
Tumblr media
Jenkins のマスターとスレーブを Docker コンテナで起動して Python の unittest を pyenv 環境で動かすまでのメモ https://ift.tt/2Jrpja5
前提 — Jenkins を動かす環境 — Python の unittest
Jenkins のコンテナの起動と初期設定 — 起動 — 初期設定
プロジェクトの設定
スレーブ環境の準備 — スレーブ環境の前提 — スレーブの追加 — プロジェクトでスレーブを利用するように設定
ビルド
以上
前提
Jenkins を動かす環境
Jenkins のマスター環境もスレーブ環境も Docker コンテナで起動する
Docker を動かすホストの OS は Ubuntu 16.04
Python の unittest
Python は pyenv を介して Python 3.6.4 を利用する
以下のようなコードとテストコードを用意した
# sample.py def foo(): return True def bar(): return True # tests/test_sample.py import unittest import sample class SampleTest(unittest.TestCase): def test_foo(self): self.assertTrue(sample.foo()) def test_bar(self): self.assertTrue(sample.bar()
以下のように実行すると, テストが走る.
$ python -m unittest tests.test_sample .. ---------------------------------------------------------------------- Ran 2 tests in 0.000s
尚, これらのコードは Backlog Git にホストする.
Jenkins のコンテナの起動と初期設定
起動
以下を実行して, Jenkins コンテナを起動する.
mkdir -p ~/sandbox/jenkins/jenkins_home cd ~/sandbox/jenkins/jenkins_home docker run --name=jenkins -d -p 8080:8080 -p 50000:50000 -v $(pwd):/var/jenkins_home jenkins/jenkins:lts
起動したら, 初期設定を進める.
初期設定
以下のような設定を行った.
認証情報
プラグインのインストール (今回は Backlog プラグインと pyenv プラグインをインストールした)
プロジェクトの設定
プロジェクトは以下のような項目の設定を行った.
General
プロジェクト名
実行するノードを制限 (後述)
ソースコード管理
リポジトリ URL (今回は Backlog Git を利用した)
認証情報 (Backlog Git の認証情報を設定)
ブランチ指定子 (全てのブランチを対象とする為, ** とした)
ビルド環境
pyenv build wrapper にチェック
The Python version に 3.6.4 を入力
ビルド
シェルスクリプトに python -m unittest tests.test_sample を入力
スレーブ環境の準備
スレーブ環境の前提
SSH ログイン出来る状態にしておく
jenkins ユーザーを作成して, マスターから SSH ログイン出来る状態にしておく (今回はパスワード認証, パスワードベタ書き)
Java 環境を用意してエージェントプログラム slave.jar が利用出来る状態にしておく
その他, ビルドに必要なパッケージを用意しておく (今回は Python インストールに必要なパッケージをインストールしておく)
最終的に以下のような Dockerfile を用意した.
FROM ubuntu:16.04 # RUN apt-get update RUN apt-get -y install sudo openssh-server openjdk-8-jdk git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev # RUN mkdir -p /var/run/sshd RUN useradd -d /home/jenkins -m -s /bin/bash jenkins RUN echo jenkins:your_password | chpasswd RUN echo 'jenkins ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # EXPOSE 22 CMD ["/usr/sbin/sshd","-D"]
以下のようにビルドしてランしておく.
docker build -t jenkins-slave . docker run --name=jenkins-slave -t -d -p 22:22 jenkins-slave
スレーブの追加
[Jenkinsの管理] > [ノードの管理] にて, [新規ノード作成] をクリックして, まずは以下のように設定.
ノード名
Permanent Agent にチェック
更に以下のパラメータを設定する.
リモートFSルート (スレーブに作成した jenkins ユーザーのホームディレクトリ /home/jenkins を指定)
起動方法 (「SSH 経由でUnixマシンのスレーブエージェント」を指定)
ホスト (コンテナの IP アドレスを入力)
認証情報 (スレーブに作成した jenkins ユーザーのパスワードを事前に Jenkins の認証情報に定義しておくと良いかなー)
Host Key Verification Strategy (Not Verifying Verification Strategy を指定)
正常にスレーブの追加が行われると, 以下のようにログが出力される.
[03/18/18 13:41:42] [SSH] Opening SSH connection to xxx.xxx.xxx.xxx:22. [03/18/18 13:41:42] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection. [03/18/18 13:41:43] [SSH] Authentication successful. [03/18/18 13:41:43] [SSH] The remote user's environment is: BASH=/bin/bash BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath BASH_ALIASES=() BASH_ARGC=() BASH_ARGV=() BASH_CMDS=() BASH_EXECUTION_STRING=set BASH_LINENO=() BASH_SOURCE=() BASH_VERSINFO=([0]="4" [1]="3" [2]="48" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu") BASH_VERSION='4.3.48(1)-release' DIRSTACK=() EUID=1000 GROUPS=() HOME=/home/jenkins HOSTNAME=030406dab1e6 HOSTTYPE=x86_64 IFS=$' \t\n' LOGNAME=jenkins MACHTYPE=x86_64-pc-linux-gnu MAIL=/var/mail/jenkins OPTERR=1 OPTIND=1 OSTYPE=linux-gnu PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PIPESTATUS=([0]="0") PPID=36 PS4='+ ' PWD=/home/jenkins SHELL=/bin/bash SHELLOPTS=braceexpand:hashall:interactive-comments SHLVL=1 SSH_CLIENT='172.17.0.2 59868 22' SSH_CONNECTION='172.17.0.2 59868 xxx.xxx.xxx.xxx 22' TERM=dumb UID=1000 USER=jenkins _=']' [03/18/18 13:41:43] [SSH] Checking java version of java [03/18/18 13:41:43] [SSH] java -version returned 1.8.0_151. [03/18/18 13:41:43] [SSH] Starting sftp client. [03/18/18 13:41:43] [SSH] Copying latest slave.jar... [03/18/18 13:41:43] [SSH] Copied 762,466 bytes. Expanded the channel window size to 4MB [03/18/18 13:41:43] [SSH] Starting slave process: cd "/home/jenkins" && java -jar slave.jar <===[JENKINS REMOTING CAPACITY]===>channel started Remoting version: 3.17 This is a Unix agent Evacuated stdout Agent successfully connected and online
プロジェクトでスレーブを利用するように設定
プロジェクトの設定に戻って, 以下の設定を行う.
General
実行するノードを制限
ラベル式 (追加したスレーブの名前を入力)
ビルド
後はプロジェクトのビルドボタンをポチッとするだけで, 以下のようにビルドが実行される.
Started by user xxxxxxxxxxxxx Building remotely on jenkins-slave in workspace /home/jenkins/workspace/my-project > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url https://xxxxxxxxxx.backlog.jp/git/FAM/my-project.git # timeout=10 Fetching upstream changes from https://xxxxxxxxxx.backlog.jp/git/FAM/my-project.git > git --version # timeout=10 using GIT_ASKPASS to set credentials > git fetch --tags --progress https://xxxxxxxxxx.backlog.jp/git/FAM/my-project.git +refs/heads/*:refs/remotes/origin/* Seen branch in repository origin/master Seen 1 remote branch > git show-ref --tags -d # timeout=10 Checking out Revision c8f3fc3b465451fbce37a1eb4789964c60ab22b5 (origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f c8f3fc3b465451fbce37a1eb4789964c60ab22b5 Commit message: "add files" > git rev-list --no-walk c8f3fc3b465451fbce37a1eb4789964c60ab22b5 # timeout=10 $ bash -c "[ -d \$HOME/.pyenv ]" $ bash -c "cd /home/jenkins/workspace/my-project && env PYENV_ROOT\=\$HOME/.pyenv PYENV_VERSION\=3.6.4 \$HOME/.pyenv/bin/pyenv local 2>/dev/null || true" $ bash -c "mkdir \$HOME/.pyenv.lock" $ bash -c "env PYENV_ROOT\=\$HOME/.pyenv PYENV_VERSION\=3.6.4 \$HOME/.pyenv/bin/pyenv versions --bare" $ bash -c "env PYENV_ROOT\=\$HOME/.pyenv PYENV_VERSION\=3.6.4 \$HOME/.pyenv/bin/pyenv rehash" $ bash -c "env PYENV_ROOT\=\$HOME/.pyenv PYENV_VERSION\=3.6.4 \$HOME/.pyenv/bin/pyenv exec pip list" $ bash -c "env PYENV_ROOT\=\$HOME/.pyenv PYENV_VERSION\=3.6.4 \$HOME/.pyenv/bin/pyenv rehash" $ bash -c "rm -rf \$HOME/.pyenv.lock" [my-project] $ /bin/sh -xe /tmp/jenkins6857290211274972615.sh + python -m unittest tests.test_sample .. ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK Finished: SUCCESS
おお, いい感じ.
本当にスレーブがビルドに使われているかどうかは, 以下のように [Jenkinsの管理] > [ノードの管理] > [スレーブ名] > [ビルド履歴] を見ると判る.
Tumblr media
以上
Jenkins を取り上げた記事なのに, スクリーンショットが殆ど無いということに気付いた.
ということで, Jenkins 職人への道のりは遠い.
元記事はこちら
「Jenkins のマスターとスレーブを Docker コンテナで起動して Python の unittest を pyenv 環境で動かすまでのメモ」
April 09, 2018 at 02:00PM
0 notes
popallo · 12 years ago
Text
Création d'alias
cd ~/ nano .bashrc
[...] if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi [...] (�� décommenter si nécessaire)
On va donc créer notre fichier .bash_aliases :
nano .bash_aliases
Et on va le remplir avec notre premier alias :
alias nom_de_notre_alias='commande de notre alias'
Il n'y a plus qu'à relancer notre session (ou lire ici) puis une fois reconnecté saisir "nom_de_notre_alias" (sans les guillemets..) dans un terminal et la(es) commande(s) que nous avons mis dans notre alias va(ont) s’exécuter !
Si cela ne fonctionne pas du premier coup, je vous recommande un petit chmod u+x sur le fichier bash_aliases :
chmod u+x .bash_aliases
0 notes