![]() |
|
||||||||||||
Linux
Setup and basic uses |
|
Related
Miscellanious Links [ edit ]
|
General Admin - the Tao of Linux/Unix administration [ edit ]
2015-08-31 updated, rickatech
Basic install
Extra steps for virtualized setups
# cat net.sh # does this need network restart afterward? ethtool -K ens192 gso off; ethtool -K ens192 tso off; ethtool -K ens192 lro off; ethtool -K ens192 gro off; ethtool -k ens192
dnf
2024-09 updated, rickatech
Elsewhere
dnf is the successor package management updater as of around 2020 for Fedora, RHEL, and CentOS since for some reason venerable yum was allegedly unfixable.
It is not uncommon for dnf commands to use a lot of memory. Combine that with cloud servers are often configured without a memory swapfile to save cost. An unfortunate result is dnf commands are killed due to insufficient memory. Turns out it can be rather easy to enable swapfile to extend usable memory on the fly, after which dnf commands run to completion - system updates and all can resume.
# dnf provides ip Killed $ swapon --show $ free -h $ df -lh $ free -m $ cat /proc/swaps $ cat /ect/fstab $ ls -lh / $ fallocate -l 1G /swapfile $ ls -lh / $ df -lh $ chmod 0600 /swapfile $ mkswap /swapfile $ swapon /swapfile $ free $ dnf provides ip [ runs fine ] # swapoff -a [ tells kernel to purge swap ] # free [ check until Swap: used 0 ] # swapon -a [ to re-enable swap, check with free that it is enabled, may need to swapon /swapfile or remove the swap file to reclaim storage ]
git
The Über alternative to version control and configuration management. As of RHEL / Centos 6 this seems to be included in standard release packages.
Related
Elsewhere
As of 2014, many system administrator are experiencing adventures introduced by the wide adopting of systemd across most popular Linux distributions. For the most part functionality is the same, but many common commands have migrated to systemd equivalents. Following is shell session excerpt from RHEL/CentOS 7 basic Apache setup leveraging systemd style commands.
# rpm -qa | grep httpd httpd-2.4.6-19.el7.centos.x86_64 # /etc/httpd/mkdir vhosts-enabled # /etc/httpd/mkdir vhosts-disabled # ls -lh /etc/httpd/vhosts-enabled/ -rw-r--r-- 1 root root 1.2K Feb 8 13:39 foo.bar.org.conf # rcsdiff /etc/httpd/conf/httpd.conf > > # vhost configs > IncludeOptional vhosts-enabled/*.conf # cat vhosts-enabled/foo.bar.org.conf <Directory "/public/foobar/site"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <VirtualHost *:80> ServerName foo.bar.org DocumentRoot /public/foobar/site ErrorLog /var/log/httpd/foo.bar.org/error.log CustomLog /var/log/httpd/foo.bar.org/requests.log combined </VirtualHost> # cat /public/foobar/site/index.html test # systemctl restart httpd # systemctl status httpd.service # tail -f /var/log/httpd/foo.bar.org/error.log # tail -f /var/log/httpd/foo.bar.org/requests.log # systemctl list-unit-files --type=service
Case-insensitive searching in vi is enabled thusly:
in command mode type :set ignorecase or :set ic
and to revert back type :set noignorecase or :set noic.
Also, consider putting set ignorecase into your vi configuration file.
File Access Control List (ACL)
2020-09 rickatech
Notice the + sign, that means an acl has been specified, and that your file system has acl enabled. Typical distros come preconfigured with acl enable, but in some cases a package may need to be installed first.
$ ls -lh -rw-rw-r-- 1 will webapp 872 Mar 19 2020 notes.txt drwxrwsr-x+ 6 will webapp 93 Sep 27 05:56 Organizations drwxr-sr-x 3 apache webapp 21 Sep 5 09:13 Organizations.Rick LLC drwxrwsr-x 5 will webapp 62 Sep 18 22:25 Projects drwxrwsr-x 2 will webapp 66 Apr 25 05:22 uploads drwxrwsr-x 2 apache webapp 6 Aug 3 07:27 Users $ getfacl Organizations # file: Organizations # owner: will # group: webapp # flags: -s- user::rwx group::rwx other::r-x default:user::rwx default:group::rwx default:mask::rwx default:other::r-x
The -m -x -d -k flags for setfacl are particular useful, as is getfacl.
Ansible is an open source remote system management toolset, recently acquired by commercial Linux vendors RedHat. It allows reasonably low effort remote server administration . Beginning users are encouraged to leave remote systems root login open to more easily get things working, with the caveat that many consider that a poor security best practice.
# yum install ansible ... # ansible --version ansible 2.2.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides # mkdir ansible; cd ansible; ssh-keygen -f ansible_rsa Generating public/private rsa key pair ... [ using -f overrides default key name, forcing more specific key parameters below ] # ls; cd .. ansible_rsa ansible_rsa.pub # ssh-copy-id -i ansible/ansible_rsa.pub c7x2ip76.local.zaptech.org Are you sure you want to continue connecting (yes/no)? yes Number of key(s) added: 1 # ssh c7x2ip76.local.zaptech.org -i ansible/ansible_rsa [ test remote key installed okay ] # rcsdiff /etc/ansible/hosts 44a45,47 > [ ip76 ] > 10.10.10.76 # ansible -m ping 'ip76' --ssh-extra-args="-i ansible/ansible_rsa" 10.10.10.76 | SUCCESS => { "changed": false, "ping": "pong" }
Restoring GRUB to MBR
Boot off install CD in rescue mode. Mount desired root partition read-write ... # chroot /mnt/sysimage # /sbin/grub-install /dev/hda |
|
# uname -a Linux linuxdv2 2.4.22-1.2114.nptlsmp #1 SMP ... # mkbootdisk --device /root/boot.iso 2.4.22-1.2115.nptlsmp -v --iso ...
LILO
Most computers decide how to boot by looking at a magic spot on
the default hard drive. This magic spot is excluded from hard partiiotning
and file system formatting. This magic spot is called the MBR (Master Boot
Record).
lilois a Linux tool for writing boot instructions to the MBR.
There are other tools by Microsoft and alternatives to lilo for Linux
for writing to the MBR, but they essentially do nothing more than what lilo
does (more about that later). As of this writing the latest lilo handles
modern BIOS's that can see past 8 GBytes
(see Hard Disks and Linux for more about this). If you
happen to be using an older lilo, you will need to make sure any bootable
partitions start below the 8 GByte threshold.
Since the MBR is read every time a system boots, you only need to run lilo
if you want to change how a system boots. Before you run lilo you need
to make sure a valid /etc/lilo.conf exists.
Basic /etc/lilo.confboot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=50 message=/boot/message lba32 default=linux image=/boot/vmlinuz-2.4.2-2 label=linux read-only root=/dev/hda2 other=/dev/hda1 optional label=dos |
Funky /etc/lilo.confboot=/dev/fd0 map=/boot/map install=/boot/boot.b #prompt #timeout=50 #message=/boot/message lba32 default=linux image=/boot/vmlinuz-2.4.2-2 label=linux vga=835 # vga=835 24 bit (e.g. Compaq Presario 1800T) # vga-834 16 bit read-only root=/dev/hda2 other=/dev/hda1 optional label=dos |
The Funky listing above disables the pause and prompt before launching
the OS after boot. The vga=835 will boot with the console in
framebuffer mode - which looks like a super wide and tall console
(like you would see on a Sun or high end Unix box). The boot=/dev/fd0 is for
making a boot floppy - sort of.
Making a Boot Floppy
Using the Funky /etc/lilo.conf listed above and running /sbin/lilo is a no frills ways to make a boot floppy. Warning, floppy disks don't have a magic MBR area, they just use the raw data area for boot instructions. This means that lilo will obliterate any file system on the floppy, but now the floppy can be used to boot the system (which is handy if the MBR on the hard disk gets wacked).
Neat Floppy Boot Tricks
|
|
Microsoft Boot Loaders
If you clobbered your MBR that had a Windows boot loader, there are ways
to reinstate it. Unfortunately this is not as easy as it is with lilo.
Alegedly Windows NT boot floppies or cdrom media can be used to get to a
restore console that allows you to run fdisk /mbr or
fixmbr. Last I tried, I had to use Windows 2000 boot cdrom, boot
to it and tell it to enter restore mode. YOU WILL NEED TO KNOW YOUR
ADMINISTRATOR PASSWORD OR NO DICE! to enter restore mode.
More ...
Beware that fdisk may show conflicting disk size information. The
following fdisk reports 500.1 GBytes, but actually holds only 465.7 GBytes = 500107862016 /
1024G / 1024M /1024K .
With fdisk you can use the P command to show a partition summary. Use D to
delete a partition, and N to create one. Use T to respecify partition type.
You might notice that the first partition is named something like hda1
(for first IDE drive). You can have four partitions per disk. In an extended
partition you can create logical partitions. The first logical partition will
be something like hda5 (for first IDE drive). The /dev directory on
root shows all the poosible names for devices and their partitions.
Drives formatted on Sparc systems and/or formatted natively under Solaris use
a peculiar partioning scheme. In some cases it may be necessary to obliterate
the partition table using badblock write mode option before partitioning
it with fdisk. Symptoms of this are inexplicable mkfs errors.
Note: there appears to be a limitation in most distributions such that
the root partition must be within the first 8 GBytes.
Generally file system integrity is checked automatically. However, for
additional disk partitions you have created and for other reasons you may
wish to know how to do this. Use fsck /dev/[partition] .
Note, it is dangerous to fsck a partition that is mounted. If
possible, unmount it first before fsck'ing it.
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Advanced Server" /fastdetect
C:\bootsect.red="RedHat Linux: hda2"
Linux & NT/W2000
Linux & Windows 9X
Possibly Obsolete: CDROMs follow this as /dev/hca and /dev/sca . Subsequent disks are hdb, hdc for IDE
and scb, scc for SCSI. Multiple CDROMs follow the same naming convention.
# fdisk -l
Disk /dev/sda: 18.2 GB, 18210036736 bytes
255 heads, 63 sectors/track, 2213 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 33 265041 83 Linux
/dev/sda2 34 98 522112+ 82 Linux swap / Solaris
/dev/sda3 99 2213 16988737+ 83 Linux
Disk /dev/sdb: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 4427 35559846 8e Linux LVM
Disk /dev/sdc: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 4427 35559846 8e Linux LVM
Disk /dev/sdd: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 4427 35559846 8e Linux LVM
Disk /dev/sde: 123.5 GB, 123522417152 bytes
255 heads, 63 sectors/track, 15017 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 * 1 15017 120624021 7 HPFS/NTFS
# df -ha
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 1.7G 14G 11% /
/dev/proc 0 0 0 - /proc
/dev/sys 0 0 0 - /sys
/dev/devpts 0 0 0 - /dev/pts
/dev/sda1 251M 9.5M 229M 4% /boot
/dev/shm 252M 0 252M 0% /dev/shm
/dev/mapper/vg1-lvpublic
99G 74G 20G 79% /public
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
automount(pid1733) 0 0 0 - /net
nfsd 0 0 0 - /proc/fs/nfsd
/public/new/hagrid_root.iso
7.9G 3.1G 4.4G 42% /mnt/h0
# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 60801 488384001 c W95 FAT32 (LBA)
Hard Disk FormattingUse mkfs thusly ...
ext2 is the file system used most with Linux. msdos
and other alternative formats can be specified fi you like.
Whoa! Huge Disks and Linux
Sometimes fdisk will complain that a huge disk partition doesn't end on
a cylinder boundary ... just ignore it, works for me. Such a monolithic
partition scheme will probably not work for a boot disk, but hey - you could
make a smaller bootable partition followed by the gianormous extended/logical
partition if you must boot from this disk.
Command (m for help): p
Disk /dev/hda: 247 heads, 228 sectors, 22505 cylinders
Units = cylinders of 56316 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 452 12714880+ 5 Extended
Partition 1 does not end on cylinder boundary:
phys=(1023, 15, 63) should be (1023, 246, 228)
/dev/hda5 1 452 12714849 83 Linux
The Art of Disk Mounting
/dev/sda1 / ext2 defaults 1 1
/dev/sda2 swap swap defaults 0 0
/dev/fd0 /mnt/floppy ext2 noauto 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
none /proc proc defaults 0 0
/dev/hda1 /mnt/tempdisk ext2 defaults 1 2
File System/Partition Checking
Partition / File System Labels
More recent version of Linux use a more sophisticated technique for declaring how a given partion should be mounted. A file system volume label can be written to the a given partition, then when mounting occurs, the mount location can be derived from the file system itself. Paradoxically, the volume label is often the same as the mount destination so the extra abstraction may seem a bit overwrought over simple specifying the raw mount location during mount time. However, it can help from 'accidentally' mounting the wrong partition. A hypothetical example is accidentally specifying a root partition as a tmp partition during a freak boot, the root parition could be wiped if it didn't have a disk label saying it was something other than /tmp.
|
# tune2fs -l /dev/sda1 tune2fs 1.35 (28-Feb-2004) Filesystem volume name: /boot Last mounted on: |
Stay tuned! | RedHat Tips |
Typically SCSI tape drives mount as /dev/st0.
In some cases the mt command may not be present, but is
typically only an rpm away.
|
# up2date -du mt-st --nosig # rpm -qf /bin/mt # su - # mt -f /dev/st0 tell # mt -f /dev/st0 status # mt -f /dev/st0 rewind # tar -cvf /dev/st0 * # mt -f /dev/st0 rewind Table of contents # tar -ztvf /dev/st0 # tar -zxvf /dev/st0 /.../... |
LVM adds an abstraction layer above typical device drivers.
Typically this is relevent only for hard disk devices.
Typically when a disk partition is mounted, the mounted volume
is directly related to a low-level disk partition. LVM allows
chunks of different disks to be collected into an abstract
volume that can be mounted just like a traditional disk partition.
Although there is a slight performance penalty for LVM, it offers
the ablilty to change the size of a partition and perform
advanced disk snapshot operations handy for doing backups without
unduly interrupting busy services.
It all starts with fdisk and assigning a partition type of 8E. Note, sometimes fdisk will report an error when exiting after such an assignment, though a reboot seems to resolve the issue.
|
# fdisk /dev/hda [ create /dev/hda4 as a Linux LVM partition ] n 4 ... t 8e (Linux LVM) # vgscan ... builds/populates /etc/lvmtab # Low-level format partition for LVM # pvcreate /dev/hda4 ... # vgcreate vg1 /dev/hda4 create # vgchange -a n vg1 deactivate # vgchange -a y vg1 activate # vgchange -a n vg1 deactivate # vgremove vg1 remove # vgcreate -s 16k vg1 /dev/hda4 create 16k PE size # mkdir /mnt/lv1 # lvcreate -L 100M -n lv1 vg1 # mkfs -t ext2 /dev/vg1/lv1 ... # mount /dev/vg1/lv1 /mnt/lv1 ... # lsof +D /mnt/lv1 # umount /mnt/lv1 # lvextend -L +10m /dev/vg1/lv1 /dev/hda4 # e2fsck -f /dev/vg1/lv1 # resize2fs /dev/vg1/lv1 # mount /mnt/lv1 # e2fsadm -L +20m /dev/vg1/lv1 [ no live mount error ] # umount /mnt/lv1 ... # e2fsadm -L +20m /dev/vg1/lv1 ... # mount /mnt/lv1 Elsewhere e2fsadm |
Elsewhere
surf.ap.seikei.ac.jp/~nakano/ |
$ cdrecord -scanbus ... $ # -v verbose $ # -eject eject cd after burn completes $ # dev=6,0 use the drive ID you see reported from cdrecord -scanbus $ # foobar.iso a prepared cd image ready for burning directly to disc $ cdrecord -v -eject dev=6,0 foobar.iso ... watch and wait ...
dd tricks
# dd if=/dev/cdrom of=cd.iso
# mount -o loop /public/new/hagrid_root.iso /mnt/h0 # ls /mnt/h0/ bin dev home lib misc opt public sbin tmp var boot etc initrd lost+found mnt proc root sys usr # df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda3 16G 1.7G 14G 11% / /dev/sda1 251M 9.5M 229M 4% /boot /dev/shm 252M 0 252M 0% /dev/shm /dev/mapper/vg1-lvpublic 99G 74G 20G 79% /public /public/new/hagrid_root.iso 7.9G 3.1G 4.4G 42% /mnt/h0
AllowRootLogin=true
Xconfigurator - once Linux is booting to a login prompt on a system's default video device, Xconfigurator is the command to attempt to configure it for the X Windows graphics environment. Its best to know what your graphics card/chip and monitor capabilites are before running this. If you succeed in having it detect your graphics capability, it is highly recomended that you decline having graphics enabled on bootup. Instead stay with text only login and use startx to bring up the graphics on demand. This will reduce headaches significantly if and when your graphics capabilities inevitably change.
Configuring X Windows Desktop Environments
(DE) - Gnome, Afterstep, FWM, KDE, ...... # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: ...
Remote X Servers
|
Elsewhere
|
Autoconf -
configure make install
|
|
This is yet another peculiar method for compiling and installing software under Linux. If you unpack some software and find Imakefile files sprinkled around it is a good bet that it expects you use xmkmf to generate a Makefile. Once a Makefile is created, should be as simple as running make much like with configure make install. It is amazing how much software uses Imakefile's but doesn't mention in the install instructions that xmkmf is the command you need to use to get things working properly.
Server# hostname foobar # rpm -qa | grep -i nfs-utils nfs-utils-1.0.9-42.el5 # rpm -qi nfs-utils The nfs-utils package provides a daemon for the kernel NFS server and related tools ... # cat /etc/exports /public 10.17.0.0/255.255.0.0(ro) # service nfs ... |
Client # ls /mnt/coolmntpt empty # mount foobar:/public /mnt/coolmntpt # ls -l /mnt/coolmntpt lots of files ... # df -h | grep cool foobar:/public ... /mnt/coolmntpt # umount /mnt/coolmntpt[ for CentOS/RHEL 7/systemd see below ] |
Security - It is easy for a client request to be spoofed allowing unauthorized access to a nfs server volume. In general it good practice to only expose nfs volumes across LAN links and not expose them to the broader Internet.
Persistence - A nfs server may not stay online indefinetly. If you regularly mount nfs volumes (i.e. you are nfs client), be familiar enough with the nfs server to know when mounting it may not be a good idea. In some cases mounting a volume from a server not online can cause unexpected delays and worst case file corruption. If you serve nfs mount points, you may want to configure your system to automatically restart nfs at boot time.
Run Levels - Make sure portmap service is running. Typically portmap is on for levels 3 and 5, but not for run level 2.
nfs - Unable to mount nfs share
As of RHEL/CentOS 7, client must also install nfs-utils and make sure rpcbind service is working.
# yum install nfs-utils # mount mini.local.zaptech.org:/public/nfs_new /mnt Job for rpc-statd.service failed. See 'systemctl status rpc-statd.service' and 'journalctl -xn' for details. # systemctl status rpcbind rpcbind.service - RPC bind service Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; static) Active: inactive (dead) # systemctl stop rpcbind # systemctl start rpcbind # systemctl status rpcbind rpcbind.service - RPC bind service Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; static) Active: active (running) since Thu 2015-05-21 03:32:14 EDT; 1s ago Process: 2847 ExecStart=/sbin/rpcbind -w ${RPCBIND_ARGS} (code=exited, status=0/SUCCESS) Main PID: 2848 (rpcbind) CGroup: /system.slice/rpcbind.service └─2848 /sbin/rpcbind -w # mount mini.local.zaptech.org:/public/nfs_new /mntMost distributions do not enable user level ftp capability by default. For RedHat you will need to install the /wu-ftpd-... RPM. This should allow authorized users to access their home directories.
# default: on # description: The wu-ftpd FTP server serves FTP connections. It uses \ # normal, unencrypted usernames and passwords for authentication. service ftp { socket_type = stream wait = no user = root server = /usr/sbin/in.ftpd server_args = -l -a log_on_success += DURATION USERID log_on_failure += USERID nice = 10 # disable = yes }
# rcsdiff ftpaccess =================================================================== *** 11,24 **** # Chroot all users to their home directory by default # (comment this out if you don't want to chroot most of your users) ! guestuser * # If you wish to allow user1 and user2 to access other # directories, use the line below: ! # realuser user1,user2 --- 11,24 ---- # Chroot all users to their home directory by default # (comment this out if you don't want to chroot most of your users) ! # guestuser * # If you wish to allow user1 and user2 to access other # directories, use the line below: ! realuser fredness,eddie
Anonymous FTP
If anonymous ftp capability is desired, install the
anonftp-... RPM. A /home/ftp directory should now exist that
anonymous users can access.
SaMBa - file sharing services that interface well with
Microsoft Windows
|
$ cat /etc/redhat-release Fedora Core release 4 (Stentz) $ rpm -qa | grep -i samba samba-common-3.0.14a-2 samba-client-3.0.14a-2 samba-3.0.14a-2 |
Tweaking file shares (circa RedHat 8.0)
diff -r1.1 /etc/samba/smb.conf 16a17,20 > # netbios name = sony-samba > netbios name = hpserv > 18c22 < workgroup = MYGROUP --- > workgroup = WORKGROUP 28c32 < ; hosts allow = 192.168.1. 192.168.2. 127. --- > hosts allow = 192.168.1. 192.168.2. 127. 53c57,58 < security = user --- > security = share 234a240,251 > # GeeWiz production folder > [geewiz] > comment = GeeWiz production folder > path = /geewiz > public = yes > writable = yes |
# rcsdiff smb.conf 18c18 < workgroup = MYGROUP --- > workgroup = WORKGROUP 21c21 < server string = Samba Server --- > server string = morpheus.us.wizbang.com 58c58,59 < security = user --- > # security = user > security = share 228,233c229,234 < ;[public] < ; comment = Public Stuff < ; path = /home/samba < ; public = yes < ; read only = yes < ; write list = @staff --- > [public] > comment = Public Stuff > path = /public > public = yes > read only = yes > write list = @staff |
SaMBa - encrypted passwords
Most version of Microsoft Windows expect encrypted passwords to be enabled. If a machine can see a SaMBa server but issues a connect/bad password error when attempting to open the server, it is a pretty good bet that the SaMBa server does not have encrypted passwords enabled. Quick way to get around this is to tweak the REGISTRY on each MS Windows system to disable encripted passwords (see above). A more compatible way to resolve this is to enable encrypted passwords.
# You may wish to use password encryption. Please read # ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation. # Do not enable this option unless you have read those documents encrypt passwords = yes smb passwd file = /etc/smbpasswd # The following are needed to allow password changing from Windows to # update the Linux sytsem password also. # NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above. # NOTE2: You do NOT need these to allow workstations to change only # the encrypted SMB passwords. They allow the Unix password # to be kept in sync with the SMB password. unix password sync = Yes passwd program = /usr/bin/passwd %u passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:* all*authentication*tokens*updated*successfully*
>cat smbusers
>cat smbpasswd
SaMBa - Domain/Group and Anonymous
# workgroup = NT-Domain-Name or Workgroup-Name workgroup = ZAPTECH
There is no anonymous user built into SaMBa that I am aware of. However, the nobody user can be given a smbpasswd of nothing. This will present users with a user passwd requestor that can be dismissed by using nobody and CR. Such users typically won't have write access. Alternatively, dispense with user authentication entirely by changing smb.conf security setting to share (see example above).
RCS (revision control system)
Classic/legacy command line file based version control. |
|
CVS (centralized source code version control)
CVS - Installation
Before spending a lot of time setting up a classic 'pserver' CVS repository, check id SSH is already available on you system. If it is then stop right there - you already have all the remote access CVS repository information you need! Typically ext CVS already associates with SSH. You will still need to setup a group and file store though.
|
# default: off # description: cvs server service cvspserver { socket_type = stream protocol = tcp wait = no user = root server = /usr/bin/cvs server_args = -f --allow-root=/home/home/cvsroot pserver }
# default: off # description: cvs server service cvspserver { socket_type = stream protocol = tcp wait = no log_on_success += USERID user = root passenv = server = /usr/bin/cvs server_args = -f --allow-root=/home/home/cvsroot pserver }
CVS - Multiple Repositories
Yes its true, you can have more than one CVS repository on a server. The
critical bit that allows this is adding another --allow-root=[path]
to /etc/xinetd.d/cvspserver for each additional repository. Each
repository will need to be initialized seperately.
CVS - Allowing Anonymous Access
Add nobody to cvs group
CVS - Read Only Users
Add the username (see below) then add username to the readers file (see above). No passwd file is required for this.
# su - ... # rpm -ivh mysql-3.23.36-1.i386.rpm ... # rpm -ivh mysql-server-3.23.36-1.i386.rpm ... # /etc/rc.d/init.d/mysqld status ... # /etc/rc.d/init.d/mysqld start ... # exit # mysql -> \h -> \q #
Which System Libraries are Installed
Check /usr/lib to see what libs are installed. Also, you can take a look at /etc/ld.so.conf to see what libs are installed and in what dir they are installed in.
If you have manually added a library to one of the existing library directories, make sure you run ldconfig to register it. Alternatively, try setting LD_LIBRARY_PATH env var to point to the desired library directory.
# export LD_LIBRARY_PATH=/usr/local/lib
$ nm -Bog /usr/X11/lib/*.so | grep XGetExtensionVersion
Bourne Again SHell (BASH), is probably the most ubiquitous command line interpreter enabled by default on Linux/Unix systems as of this writing. As such, there are many powerful commands and other capabilities built into bash that are important to master to effective manage and administer a wide variety of computer systems.
Useful way to to detach a session from the current login session, then resurrect it later. Very hand for monitoring/running commands that take a very long time to complete, and not having to be sitting at the hardware.
$ screen -ls No Sockets found in /var/run/screen/S-ricks. $ screen $ screen -ls There is a screen on: 1067.pts-1.clamps (Detached) $ [ctrl-A]d [ ... detaches from current session ... ] $ screen -ls There is a screen on: 1067.pts-1.clamps (Detached) $ screen -r 1067.pts-1.clamps $ exit $ screen -ls No Sockets found in /var/run/screen/S-ricks.
fortune, configuring your own fortune teller
$ cat foo fortune test 1 % fortune text 2 % fortune text 3 $ strfile foo $ ls foo* foo foo.dat $ fortune foo ...
rsync -azv -e 'ssh' sourcedir user@host:/destdir
# default: on # description: The telnet server serves telnet sessions; it uses \ # unencrypted username/password pairs for authentication. service telnet { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID # restrict telnet access to internal network only_from = 192.168.1.0/24 # disable = yes }
Though consider somehow a hostile act by some, scanning
networks to check host and service settings is incredibly useful.
True, neodowells use network scanning to find servers to exploit,
however its the user's intent of a tool that needs to be judged - not
the tool itself.
That said, nmap is a network scanning tool. Great for checking that your firewall is working ias expected. |
|
$ nmap -A -T4 cp2.foobar.com Interesting ports on 216.240.133.161: (The 1671 ports scanned but not shown below are in state: filtered) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 3.9p1 (protocol 2.0) 80/tcp open http Apache httpd 2.0.52 ((Red Hat)) 873/tcp open rsync (protocol version 28) Nmap finished: 1 IP address (1 host up) scanned in 38.079 seconds $ nmap -A -T4 cp1.foobar.com Interesting ports on 216.240.159.214: (The 1669 ports scanned but not shown below are in state: filtered) PORT STATE SERVICE VERSION 20/tcp closed ftp-data 21/tcp open ftp vsftpd 2.0.1 22/tcp open ssh OpenSSH 3.9p1 (protocol 2.0) 80/tcp open http Apache httpd 2.0.52 ((Red Hat)) 443/tcp closed https Service Info: OS: Unix Nmap finished: 1 IP address (1 host up) scanned in 55.310 seconds
named - Internet DNS (Domain Name Service)
Don't venture here unless you have access to a pretty elaborate setup (at least a subnet with 2 dedicated IP addresses and servers). Although DNS in principle is pretty straight forward, one mis-step and alot of machines can drop off the net.
$ host -t any zaptech.com r2d2.inow.com Using domain server: Name: r2d2.inow.com Address: 198.144.96.10#53 Aliases: zaptech.com has SOA record public.zaptech.com. info.zaptech.com. 2005021501 10800 1800 604800 86400 zaptech.com name server r2d2.inow.com. zaptech.com name server public.zaptech.com. zaptech.com has address 198.144.98.62 zaptech.com mail is handled by 10 mail.zaptech.com. $ dig @b.root-servers.net scpns.org ; <<>> DiG 9.2.3rc1 <<>> @b.root-servers.net scpns.org ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28076 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 6, ADDITIONAL: 8 ;; QUESTION SECTION: ;scpns.org. IN A ;; AUTHORITY SECTION: org. 172800 IN NS TLD1.ULTRADNS.NET. org. 172800 IN NS TLD2.ULTRADNS.NET. org. 172800 IN NS TLD3.ULTRADNS.org. org. 172800 IN NS TLD4.ULTRADNS.org. org. 172800 IN NS TLD5.ULTRADNS.INFO. org. 172800 IN NS TLD6.ULTRADNS.CO.UK. ;; ADDITIONAL SECTION: TLD1.ULTRADNS.NET. 172800 IN AAAA 2001:502:d399::1 TLD1.ULTRADNS.NET. 172800 IN A 204.74.112.1 TLD2.ULTRADNS.NET. 172800 IN A 204.74.113.1 TLD3.ULTRADNS.org. 172800 IN A 199.7.66.1 TLD4.ULTRADNS.org. 172800 IN AAAA 2001:502:100e::1 TLD4.ULTRADNS.org. 172800 IN A 199.7.67.1 TLD5.ULTRADNS.INFO. 172800 IN A 192.100.59.11 TLD6.ULTRADNS.CO.UK. 172800 IN A 198.133.199.11 ;; Query time: 27 msec ;; SERVER: 192.228.79.201#53(b.root-servers.net) ;; WHEN: Tue Jul 4 01:43:21 2006 ;; MSG SIZE rcvd: 341
$ dig @TLD2.ULTRADNS.NET scpns.org ; <<>> DiG 9.2.3rc1 <<>> @TLD2.ULTRADNS.NET scpns.org ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53360 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 1 ;; QUESTION SECTION: ;scpns.org. IN A ;; AUTHORITY SECTION: scpns.org. 86400 IN NS ns1.zaptech.org. scpns.org. 86400 IN NS ns1.sparkworx.com. ;; ADDITIONAL SECTION: ns1.zaptech.org. 86400 IN A 64.32.175.104 ;; Query time: 25 msec ;; SERVER: 204.74.113.1#53(TLD2.ULTRADNS.NET) ;; WHEN: Tue Jul 4 01:59:23 2006 ;; MSG SIZE rcvd: 100 $ dig @172.16.4.20 howtolabs.net axfr ; <<>> DiG 9.3.1 <<>> @172.16.4.20 howtolabs.net axfr ; (1 server found) ;; global options: printcmd howtolabs.net. 86400 IN SOA ns1.zaptech.org. info.zaptech.com. 2006052001 28800 7200 604800 86400 howtolabs.net. 86400 IN NS ns1.zaptech.org. howtolabs.net. 86400 IN NS ns1.sparkworx.com. howtolabs.net. 86400 IN TXT "v=spf1 include:fc5.zaptech.org ~all" howtolabs.net. 86400 IN MX 10 fc5.zaptech.org. howtolabs.net. 86400 IN A 64.32.175.104 www.howtolabs.net. 86400 IN A 64.32.175.104 howtolabs.net. 86400 IN SOA ns1.zaptech.org. info.zaptech.com. 2006052001 28800 7200 604800 86400 ;; Query time: 21 msec ;; SERVER: 172.16.4.20#53(172.16.4.20) ;; WHEN: Mon Jul 17 16:35:42 2006 ;; XFR size: 8 records (messages 1)
More recent releases of Fedora Core Linux have SELinux enabled by default. For all but the most serious deployments (which arguably should not be using Fedora Core in the first place), this is a big headache. Essentially this adds another level of file attributes beyond those for user, group, and world. Any changes to system files without also tuning the SELinux policies and file attributes can cause all sorts of weird kernel error messages. It's also almost impossible to removed SELinux once it has been installed - instead it is better to disable the SELinux config file and reboot.
$ diff -r1.1 /etc/selinux/config 6c6,7 < SELINUX=enforcing --- > # LINUX=enforcing > SELINUX=permissive
SELinux (when enabled), adds four new file attributes: user, role, type, range. As root use chcon to modify SELinux file attributes.
# cd /var/www/icons # ls -lhZ -rw-r--r-- root root system_u:object_r:httpd_sys_content_t a.gif -rw-r--r-- root root system_u:object_r:httpd_sys_content_t alert.black.gif ... -rw-r--r-- root root user_u:object_r:httpd_sys_content_t the-hyperchicken-87721.jpg ... -rw-r--r-- root root system_u:object_r:httpd_sys_content_t world2.gif -rw-r--r-- root root system_u:object_r:httpd_sys_content_t world2.png # chcon -t httpd_sys_content_t the-hyperchicken-87721.jpg # chcon -u system_u the-hyperchicken-87721.jpg # ls -lhZ the-hyperchicken-87721.jpg -rw-r--r-- root root system_u:object_r:httpd_sys_content_t the-hyperchicken-87721.jpg
NetworkManager
For the most part, NetworkManager is a GUI for use by non-server Linux installs. Often its presence is made known by NM_ directive in the /etc/sysconfig/network-scripts/ifcfg-eth0.
Elsewhere: convirture
Nagios is a popular web service that is employed to monitor various systems and services. It's become much easier to setup recently, but still suffers from being 'over-engineered' and brittle to the extend that it will stop working for no apparent reason. Still, its popularity is steadily increasing and overall it seems to be becoming easier to setup and more stable.
nagios Service Dies, Restart Keeps Dying
Nagios tends to die for having too large a file open (signal SIGXFSZ).
It turns out that performance data is being written to a file that is not rotated
by default, so it grows until it is too large to open.
An entry in the logrotate configuration is needed, so the file will be rotated
and compressed on a weekly basis, followed by restarting Nagios.
Hopefully that keeps the problem from recurring.
$ pwd /usr/local/nagios/var $ ls -lh total 2.3G drwxrwxr-x 2 nagios nagios 16K Jan 11 16:41 archives -rw-rw-r-- 1 nagios nagios 552K Jan 14 09:06 nagios.debug -rw-rw-r-- 1 nagios nagios 977K Jan 14 09:06 nagios.debug.old -rw-r--r-- 1 nagios nagios 5 Jan 14 08:03 nagios.lock -rw-rw-r-- 1 nagios nagios 45K Jan 14 09:03 nagios.log -rw-r--r-- 1 nagios nagios 416K Jan 14 08:03 objects.cache -rw------- 1 nagios nagios 505K Jan 14 09:03 retention.dat drwxrwsr-x 2 nagios nagios 4.0K Jan 14 08:03 rw -rw-rw-r-- 1 nagios nagios 879K Jan 14 09:06 service-perfdata -rw-rw-r-- 1 nagios nagios 267M Jan 14 08:05 service-perfdata.1.gz -rw-rw-r-- 1 nagios nagios 2.0G Jun 14 2009 service-perfdata.save drwxrwxr-x 3 nagios nagios 4.0K Jan 16 2009 spool -rw-rw-r-- 1 nagios nagios 502K Jan 14 09:06 status.dat $ cat /etc/logrotate.conf ... # system-specific logs may be also be configured here. /usr/local/nagios/var/service-perfdata { rotate 52 compress nocreate postrotate /sbin/service nagios restart endscript }
SuSE/Novell Distribution Notes
Yast (yast, yast2) is the supported method for perform updates with SuSE Linux.Yum is feature equivelent to the venerable up2date RPM Manager provided by Red Hat.
Red Hat has announced end of life support for up2date for general use.
|
|
When Red Hat Linux 9.0 official support ends in 2004, the only
'free RedHat-like' Linux with up2date support will be the Fedora distribution
[ fedora.redhat.com ].
|
|
# rpm -q rpm rpmdb: unable to join the environment error: db4 error(11) from dbenv->open: Resource temporarily unavailable error: cannot open Packages index using db3 - Resource temporarily unavailable (11) error: cannot open Packages database in /var/lib/rpm package rpm is not installed Now it works when the following is done!!!!! # rm /var/lib/rpm/__* # export LD_ASSUME_KERNEL=2.2.5 # rpm -q rpm rpm-4.2.1-0.30
For those who are comfortable using Red Hat Enterprise Linux (RHEL), but don't want to pay the fees for routine updates and support, CentOS is source code equivalent. It's more stable than Rawhide and Fedora which are also based on the same source code
udev Confuses Network Settings after Cloning a Virtual Machine
Elsewhere
It seems variants of Red Hat Enterprise Linux 6 can behave strangely after files are copied from an already working virtual machine file set. The work around is simple, wipe away the cached values that udev uses and reboot. Most hypervisors will change the MAC Address for a network interface when it notices a virtual machine has been copied, which for some reason RHEL6 is more sensitive to.
(as of 2014-03, the following seems only to apply for pre-CentOS 6)
# service network stop # rm /etc/udev/rules.d/70-persistent-net.rules # rmmod vmxnet # modprobe vmxnet # shutdown -h now
rpm - command line software package management tool
|
The rhnsd service provides ... stay tuned.
# service rhnsd status rhnsd (pid 6262) is running... # chkconfig --list | grep rhn rhn-virtualization-host 0:off 1:off 2:on 3:on 4:on 5:on 6:off rhnsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # rhn_check
Typically this requires editing /etc/sysconfig/network and rebooting.
$ cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=public.zaptech.com GATEWAY=192.168.1.1
Hostname is a somewhat abstract concept. By itself it is just a simple name used by the system internally. Classic example is the host identifier text of a shell prompt. Strictly speaking this value is not known by a system until it is set sometime after boot. Red Hat convention is to place fully qualified hostname (shortname.domain.com) value in /etc/sysconfig/network which is read early during system boot (changing this will only affect system after next boot). Another convention is to place the short hostname at the end of the /etc/hosts line for 127.0.0.1/localhost. This is allows internal processes to access local resources using network connection protocols. Lastly, there is a system command called hostname. It is the key to retrieving and changing a system's internal hostname. Note: the hostname command specifically DOES NOT save any state for the next time the system boots.
Expert Install Mode
Even a simple install may require expert install mode
if a SCSI controller or network card support is desired. Also,
as of RedHat 6.X, the installer no longer allows full custom
disk partitioning with fdisk unless you specify
boot: expert text at install prompt and later indicate
a full custom installation
192.168.30.33 fredness fredness.cacheon.com
207.5.50.250 mail.zaptech.com mail
(see Red Hat)