مدیریت سرورها

آموزش مدیریت سرورهای لینوکس و ویندوز

مدیریت سرورها

آموزش مدیریت سرورهای لینوکس و ویندوز

سایت در باره انواع آموزشها در زمینه IT می باشد.
مانند: لینوکس، ویندوز، سیسکو، میکروتیک، طراحی وب
به دلیل شخصی بودن وبلاگ ارائه مطالب متفرقه در آن بلامانع است.
با تشکر

طبقه بندی موضوعی

۶ مطلب با کلمه‌ی کلیدی «bash» ثبت شده است

۰۱
آبان

For commenting a block of text is almost the same: First, go to the first line you want to comment, press CtrlV, and select until the last line. Second, press ShiftI#Esc (then give it a second), and it will insert a # character on all selected lines.

  • طاهر ضیائی
۲۳
تیر
# a.sh
num=42
# b.sh
. ./a.sh
echo $num

The variables in "a" do not need to be exported.

  • طاهر ضیائی
۰۶
تیر
if your login shell is csh or tcsh, and you have installed

bash in /usr/gnu/bin/bash, add the following line to ~/.login:

if ( -f /usr/gnu/bin/bash ) exec /usr/gnu/bin/bash --login

  • طاهر ضیائی
۰۴
تیر

The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ; they can display colors and formatted texts thanks to escape sequences. Those sequences are composed of the Escape character (often represented by ”^[” or ”<Esc>”) followed by some other characters: ”<Esc>[FormatCodem”.

In Bash, the <Esc> character can be obtained with the following syntaxes:

  • \e
  • \033
  • \x1B

Examples:

Code (Bash) Preview
echo -e "\e[31mHello World\e[0m"
Hello World
echo -e "\033[31mHello\e[0m World"
Hello World

NOTE¹: The -e option of the echo command enable the parsing of the escape sequences.

NOTE²: The ”\e[0m” sequence removes all attributes (formatting and colors). It can be a good idea to add it at the end of each colored text. ;)

NOTE³: The examples in this page are in Bash but the ANSI/VT100 escape sequences can be used in every programming languages.

  • طاهر ضیائی
۲۱
مهر

In Debian:

Check your /root/.bashrc file for these lines

if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi

If they do not exist add them to the end of the file using your favorite text editor.


In CentOS:

# yum install bash-completion

How do I use bash Autocomplete feature?

  • طاهر ضیائی
۰۸
تیر

$ cd
$ vi .bash_profile

OR
$ vi $HOME/.bashrc
Append the following line:
export PS1="\e[0;31m[\u@\h \W]\$ \e[m"
Save and close the file.

To do this changing you must logout an login again.

A list of color codes

Color Code
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33

Note: You need to replace digit 0 with 1 to get light color version.



----------------------------- In Ubuntu 14.4 --------------------------

Run the following command in a terminal:

gedit ~/.bashrc

When .bashrc opens, locate and uncomment force_color_prompt=yes (that is, remove the hash, so it no longer looks like: #force_color_prompt=yes).

Save the file, and open a new terminal window, and you should already see a change (the prompt should be Light Green, which is defined by 1;32). You can then change any colour value you like; eg: 0;35 = Purple.

To edit the colour values, locate the following section, and change the default values with some of the examples listed further down:

if [ "$color_prompt" = yes ]; then
    PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;31m\]\w\[\033[00m\]\$ 
else
    PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 
fi

You can check out this Bash colour chart for a full range of colour values, but here are a few basic ones you can play around with (note that “Light” isn’t what you might think – it actually means “bold”): Black 0;30 – Dark Gray 1;30 – Blue 0;34 – Light Blue 1;34 – Green 0;32 – Light Green 1;32 – Cyan 0;36 – Light Cyan 1;36 – Red 0;31 – Light Red 1;31 – Purple 0;35 – Light Purple 1;35 – Brown 0;33 – Yellow 1;33 – Light Gray 0;37 – White 1;37

For example, here is the line that I use it:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;34m\] \w\[\033[01;37m\] > '


  • طاهر ضیائی