Linux Server

From QwikITedia

Jump to: navigation, search

Contents

CentOS CheatSheet


How to access the CD rom on CentOS

How to unmount the CDRom

How to mount a USB drive if the system has two drives(sda and sdb)

How to unmount the USB drive

Install the RPM Key

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-3

Reinstall SeaMonkey if you've installed the Server GUI

yum install seamonkey

Install GNU C / C++ compiler on CentOS Linux server

yum install gcc gcc-c++ autoconf automake

Update existing packages on the fresh CentOS install

yum -y update

Clean out the yum cache to re-capture disk spaced used during the update process

yum clean all

Install CPAN

# perl -MCPAN -e '$ENV{FTP_PASSIVE} = 1; install CPAN'

Establish Locate or Search Index

# updatedb

Gentoo Tricks

How to Create a User account on Gentoo Server

# useradd -m -G users john
# passwd john
New password: (Enter john's password)
Re-enter password: (Re-enter john's password)


How do I grant someone sudo access

vi /etc/group 
visudo

How to Correlate MAC address with NIC

  1. /etc/conf.d/net .. change the eth0 to eth2
  2. /etc/init.d/net.eth0 .. rename this file as net.eth2 and ensure the symlink to net.lo works

Redhat Tricks

EXIT X Server

CTRL-ALT-F2

Exit X Server to install nvidia drivers


Log Whereabouts

/var/log

Grant SUDO to a normal user on REdhat

How to change from Dynamic to Static IP

BOOTPROTO=DYNAMIC
BOOTPROTO=STATIC
IPADDR=(type ip address here)
/etc/init.d/network stop
/etc/init.d/network start
/sbin/ifconfig

How to change computer name

cp /etc/hosts /etc/old.hosts.safe

How do I update my BIOS on a Dell desktop/laptop

This does not apply to Dell Rack Servers

rpm -ivh biosdisk-0.75-2.noarch.rpm
biosdisk mkpkg /home/resmonde/a11GX620.exe

Sudo on REDHAT

[root@qaserver root]# visudo
[resmonde@qaserver resmonde]$ sudo bash

Users and Groups

Networking on RedHAT

Search for a string in an Apache Conf file

fgrep -i 'ExecCGI' `find . -iname '*.conf' -print`


Ubuntu Tricks

Check to see if a package is installed or not

dpkg -l | grep <packagename>

Completely Remove a stubborn package that seems to persist

aptitude purge r-base-core

if that didn't work:

aptitude install r-base-core && aptitude purge r-base-core

Check what version of a Package Is Installed on Ubuntu

dpkg -s <packagename>


How do I Access CD Rom ..cli

mount /dev/cdrom /media/cdrom or mount /dev/cdrom /cdrom
cd /media/cdrom or cd /cdrom
ls -alF

How do I Access USB memory Stick

mount /dev/sdc1 /mnt

How do I add or edit nameservers for DNS resolution

#vi /etc/resolv.conf
search mycompany.lan
nameserver 12.x.x.x
nameserver 12.x.x.x

How do I change my Ubuntu systems time zone?

How do I install an exact Package on Ubuntu

     # apt-get install package=version
     # apt-get install nautilus=2.2.4-1

How long has my Ubuntu Server been up?

     # uptime

What ports is my Linux system listening on

 # netstat -l

What ports sans UNIX sockets are open?

netstat -tna

What Processes are running

 # ps -A

What ports are actively listening and what for

 # netstat -tulnap

Who has recently been connected to my server?

     # last -x

How to List the installed software on my Ubuntu Server for a future restore

# dpkg --get-selections
# dpkg --get-selections > /backup/installed-software.log
# dpkg --set-selections < /backup/installed-software.log


How much RAM is in my Linux system?

vi /proc/meminfo

How to Change the default Editor from nano to X on Ubuntu

root@myserver:~# sudo update-alternatives --config editor
There are 4 alternatives which provide `editor'.

  Selection    Alternative
-----------------------------------------------
          1    /usr/bin/vim.tiny
          2    /bin/ed
*+        3    /bin/nano
          4    /usr/bin/emacs22
Press enter to keep the default[*], or type selection number: 1
Using '/usr/bin/vim.tiny' to provide 'editor'.

How to Change the HOSTNAME of an Ubuntu System from CLI

# sudo echo "NEW-Server-NAME" > /etc/hostname
* sudo /etc/init.d/hostname.sh

How to learn Disc usage in general

df -h

How to learn Size of Current Directory

du -h
cd /iscsi/
du -sk ./postgresql/

How to check the version of a package already installed

aptitude show <package name>
aptitude show php5

How to Change the TIMEZONE on an Ubuntu Server

TZ='PST-8';
export TZ
date

How to RESET the TIMEZONE back to UTC on an Ubuntu Server

TZ=GST-0
TZ='GST-0';
export TZ
source ~/.profile
date

Install R on Ubuntu Hardy Heron v 8.04.x Server

# Get the latest Build of R
deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu hardy/
deb http://us.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev

Where is the Network Card?

# /etc/init.s/networking start
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
SIOCSIFADDR: No such device
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
# /etc/udev/rules.d/70-persistent-net.rules
# shutdown -r now
# /etc/init.d/networking stop
# /etc/init.d/networking start
* Ensure you can ping an internal resource
<pre># ping 10.5.5.254
# ping www.google.com

After Virtualization something is missing

apt-get locate
updatedb

What Ubuntu version am I running?

sudo lsb_release –a
Personal tools
Namespaces
Variants
Actions
Richard Esmonde.com
Wiki Navigation
Toolbox