Примеры файлов

.bashrc

#!/bin/bash
# author : an
# version : v0.7
# date : 2016_05_18

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

################################
# History
################################
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
shopt -s histappend # append to the history file, don't overwrite it
HISTSIZE=100000
HISTFILESIZE=200000
# add command into .bash_history immediately, not with the end of the session
# useful with multiple sessions
PROMPT_COMMAND='history -a;history -n'
export HISTTIMEFORMAT='%F %T ' # log with datestamp


# 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)"

################################
# PS1 and colors
################################
# more about PS1 http://habrahabr.ru/post/269967/
# func to set prompt
set_prompt () {
    Last_Command=$? # Must come first!
    Blue='\[\e[01;34m\]'
    White='\[\e[01;37m\]'
    Red='\[\e[01;31m\]'
    Green='\[\e[01;32m\]'
    Reset='\[\e[00m\]'
    FancyX='\342\234\227'
    Checkmark='\342\234\223'


    # Add date
    PS1="\t "


    # Add a bright white exit status for the last command
    #PS1+="$White\$? "

    # If it was successful, print a green check mark. Otherwise, print
    # a red X.
    if [[ $Last_Command == 0 ]]; then
        PS1+="$Green$Checkmark "
    else
        PS1+="$Red$FancyX "
    fi
    # If root, just print the host in red. Otherwise, print the current user
    # and host in green.
    if [[ $EUID == 0 ]]; then
        PS1+="$Red\\h "
    else
        PS1+="$Green\\u@\\h "
    fi

    # Print the working directory in blue and reset
    # the text color to the default
    PS1+="$Blue\\w$Reset "
    # git status parse

    GIT_NOT_FOUND=""                  #Nothing
    GIT_PROMPT_STAGED="${White}● "    # staged files/directories
    GIT_PROMPT_CLEAN="${White}✔ "     # clean repo

    # are we on repo?
    if [[ "$(git rev-parse --git-dir 2> /dev/null)" = '.git' ]]; then
        # on repo

        # create msg to print about repo
        GIT_MSG=""

        # check branch
        GIT_BRANCH=`git branch | grep \* | cut -c3-`
        GIT_MSG+="$GIT_BRANCH "

        # get msg len
        # +2 is for PROMPT sig
        MSG_LEN=$(( ${#GIT_MSG} + 2 ))

        # check status
        GIT_STATUS=`git status --porcelain 2> /dev/null`
        if [[ -z $GIT_STATUS ]]; then
            GIT_MSG+=$GIT_PROMPT_CLEAN
        else
            GIT_MSG+="$GIT_PROMPT_STAGED"
        fi

        # move to right modifier
        # uses tput to move next message to position (right - MSG_LEN)
        toend=$(tput hpa $(tput cols))$(tput cub $MSG_LEN)
        PS1+="${toend}${GIT_MSG}"
    else
        # not on repo
        PS1+=$GIT_NOT_FOUND
    fi
    # reset colors; add newline and $ sign
    PS1+="$Reset\n\\\$ "
}

# 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) 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='\t ${debian_chroot:+($debian_chroot)}\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PROMPT_COMMAND='set_prompt'
else
    PS1='\t ${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 dmesg='dmesg --color=always'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    alias gcc='gcc -fdiagnostics-color=always'
fi

################################
# alias
################################

# 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

# vi-mode breaks ctrl-L to clear screen
# fix it in .inputrc
#set -o vi # vi-mode
/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>

# /dev/sdb2
UUID=2f7c9df8-bd3c-4fc5-87b8-7c6862539385    /    btrfs    rw,relatime,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@	0 0

# /dev/sdb1
UUID=8390-998B      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/sdb2
UUID=2f7c9df8-bd3c-4fc5-87b8-7c6862539385	/.snapshots	btrfs     	rw,relatime,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@.snapshots	0 0

# /dev/sdb2
#UUID=2f7c9df8-bd3c-4fc5-87b8-7c6862539385	/home     	btrfs     	rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@home	0 0

# /dev/sdb2
UUID=2f7c9df8-bd3c-4fc5-87b8-7c6862539385	/var/cache/pacman/pkg	btrfs     	rw,relatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@pkg	0 0

# /dev/sdb2
UUID=2f7c9df8-bd3c-4fc5-87b8-7c6862539385	/var/log  	btrfs     	rw,relatime,ssd,compress=zstd:2,discard=async,space_cache=v2,subvolid=258,subvol=/@log	0 0

#параметры монтирования отдельного диска для /home
/dev/sda1 /home ext4 rw,noatime,data=ordered    0 0
iptables файл
# Generated by iptables-save v1.8.7 on Mon Jun  5 05:22:47 2023
*mangle
:PREROUTING ACCEPT [2792598:2636682306]
:INPUT ACCEPT [585614:136618282]
:FORWARD ACCEPT [2206984:2500064024]
:OUTPUT ACCEPT [2111567:2545800648]
:POSTROUTING ACCEPT [4318279:5045813253]
COMMIT
# Completed on Mon Jun  5 05:22:47 2023
# Generated by iptables-save v1.8.7 on Mon Jun  5 05:22:47 2023
*filter
:INPUT DROP [933:45147]
:FORWARD ACCEPT [611:71673]
:OUTPUT ACCEPT [2111295:2545749229]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 1194 -j ACCEPT
-A INPUT -i tun0 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5565 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 68 -j ACCEPT
-A FORWARD -i tun0 -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o tun0 -j ACCEPT
COMMIT
# Completed on Mon Jun  5 05:22:47 2023
# Generated by iptables-save v1.8.7 on Mon Jun  5 05:22:47 2023
*nat
:PREROUTING ACCEPT [24606:2944886]
:INPUT ACCEPT [9908:566032]
:OUTPUT ACCEPT [171:13193]
:POSTROUTING ACCEPT [2495:221733]
-A POSTROUTING -s 10.10.10.0/28 -o eth0 -j MASQUERADE
COMMIT
# Completed on Mon Jun  5 05:22:47 2023
virc,vimrc
set number
set showmode
set tabstop=3
set shiftwidth=3
set smarttab
set et
set nowrap
set ai
set cin
set showmatch
set hlsearch
set incsearch
set ignorecase
set listchars=tab:··
set list
set smartcase
set showcmd
nanorc
set historylog
set indicator
set jumpyscrolling
set linenumbers
set locking
set minibar
set mouse
smb.conf + # smbpasswd -a [username_to_add]
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
#  http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
   workgroup = WORKGROUP
   netbios name = visbox

# server string is the equivalent of the NT Description field
   server string = Samba Server

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
   server role = standalone server

# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
   hosts allow = 192.168.1. 127.

# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
;  guest account = pcguest

# this tells Samba to use a separate log file for each machine
# that connects
   log file = /usr/local/samba/var/log.%m

# Put a capping on the size of the log files (in Kb).
   max log size = 50

   server min protocol = SMB2_02
   deadtime = 30
   server smb encrypt = desired
# Specifies the Kerberos or Active Directory realm the host is part of
;   realm = MY_REALM

# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
;   passdb backend = tdbsam

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting.
# Note: Consider carefully the location in the configuration file of
#       this line.  The included file is read at that point.
;   include = /usr/local/samba/lib/smb.conf.%m

# Configure Samba to use multiple interfaces
# If you have multiple network interfaces then you must list them
# here. See the man page for details.
;   interfaces = 192.168.12.2/24 192.168.13.2/24

# Where to store roving profiles (only for Win95 and WinNT)
#        %L substitutes for this servers netbios name, %U is username
#        You must uncomment the [Profiles] share below
;   logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
;   wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
#       Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
;   wins server = w.x.y.z

# WINS Proxy - Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one  WINS Server on the network. The default is NO.
;   wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The default is NO.
   dns proxy = no

# These scripts are used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
;  add user script = /usr/sbin/useradd %u
;  add group script = /usr/sbin/groupadd %g
;  add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
;  delete user script = /usr/sbin/userdel %u
;  delete user from group script = /usr/sbin/deluser %u %g
;  delete group script = /usr/sbin/groupdel %g


#============================ Share Definitions ==============================
#раскомментировать для доступа к домашним директориям
;[homes]
;   comment = Home Directories
;   browsable = no
;   writable = yes

# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
;   comment = Network Logon Service
;   path = /usr/local/samba/lib/netlogon
;   guest ok = yes
;   writable = no
;   share modes = no


# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;[Profiles]
;    path = /usr/local/samba/profiles
;    browsable = no
;    guest ok = yes


# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
;[printers]
;   comment = All Printers
;   path = /usr/spool/samba
;   browsable = no
# Change 'guest ok' from 'no' to 'yes' to allow the 'guest account' user to print
;   guest ok = no
;   writable = no
;   printable = yes

# This one is useful for people to share files
;[tmp]
;   comment = Temporary file space
;   path = /tmp
;   read only = no
;   public = yes

# A publicly accessible directory, but read only, except for people in
# the "staff" group
;[public]
;   comment = Public Stuff
;   path = /home/samba
;   public = yes
;   writable = no
;   printable = no
;   write list = @staff

# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# home directory. Note that fred must have write access to the spool directory,
# wherever it is.
;[fredsprn]
;   comment = Fred's Printer
;   valid users = fred
;   path = /homes/fred
;   printer = freds_printer
;   public = no
;   writable = no
;   printable = yes

# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir]
;   comment = Fred's Service
;   path = /usr/somewhere/private
;   valid users = fred
;   public = no
;   writable = yes
;   printable = no

# a service which has a different directory for each machine that connects
# this allows you to tailor configurations to incoming machines. You could
# also use the %U option to tailor it by user name.
# The %m gets replaced with the machine name that is connecting.
;[pchome]
;  comment = PC Directories
;  path = /usr/pc/%m
;  public = no
;  writable = yes

# A publicly accessible directory, read/write to all users. Note that all files
# created in the directory by users will be owned by the default user, so
# any user with access can delete any other user's files. Obviously this
# directory must be writable by the default user. Another user could of course
# be specified, in which case all files would be owned by that user instead.
;[public]
;   path = /usr/somewhere/else/public
;   public = yes
;   only guest = yes
;   writable = yes
;   printable = no

# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
[Storage]
;   comment = Mary's and Fred's stuff
   path = /media/storage
   valid users = vision
   public = no
   writable = yes
;   printable = no
   create mask = 0755

Last updated