Here is my (very) rough guide for administering Linux from a Windows perspective. As a Windows Admin the key point to take from this is that different versions of Linux and Unix have slightly different setups so the guide may be wrong for the specific flavour of Linux you are using. I work with RHEL & Debian Linux.
Background
I put this together (in a previous role) when my team started supporting servers in a heterogeneous environment. The support teams are dived by skills e.g. Microsoft, Linux, Firewalls & Networks (FNS), Oracle DBAs or MS SQL DBAs but I feel that it is important to get hands on with as much tech as possible to be well rounded hence getting Windows guys to do 1st/2nd line Linux support. With this in mind
RedHat Enterprise (RHEL) Manuals
https://www.redhat.com/docs/manuals/enterprise/
Debian
http://www.debian.org/doc/user-manuals
http://www.debianadmin.com
Caution: Every command in Linux-like operating systems is CaSe sEnsiTive. ROOT for example isn’t the same as Root or root. This is an example of three different user accounts, only root is the administrator account.
Processes (Services)
Live in /etc/init.d/
Use ps -ef to show running processes. Then add grep to limit the out put to the process your interested in.
ps -ef | grep "process name"
Ps -ef | grep sendmail
Find a process based on process id (may be recorded in a log file)
OR
top ( Ctrl + C to exit )
Useful process related commands
kill
Kill a process
kill "process id"
kill -9 "process id" Kills the process immediately without question
service stop / start / restart
service –status-all | grep running
Show running services
service –status-all | grep stopped
Show stopped services
service name start/stop/restart
service httpd start
Error Logs
Logs tend to be in /var/log/
e.g. /var/log/audit/audit.log
cat /path/filename to display content
cat /var/log/audit/audit.log
tail
Tail /path/filename shows new entries to a file as they are written. good for monitoring log files
tail -f /var/log/audit/audit.log
Permissions
Chmod
Change permissions on a file
http://www.computerhope.com/unix/uchmod.htm
chown
Changes the owner of a file directory
chown [-R] newowner filenames
-R recursively change every file / dir to designated user
chroot
A command to lock user to their home directory as the root
http://www.ss64.com/bash/chroot.html
users
Useradd -h – displays help
Create a user with a home directory and a member of a group or groups
Useradd -d /home/myuser -G myuser -m myuser
Set password for user
Password myuser "password"
Disk info
df -h
fdisk -l display disk layout
parted
(parted) print
isplay info not working on my VM
(parted) help :display help
(parted) quit :exit parted
Tools
Putty – SSH
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
This is a tool that enables you to SSH to the console of the box you want to manage. Please note that by default root is not allowed to SSH to console. You may need to use SU – to change to root once you have SSH’ed in with a different account.
WinSCP
like FTP / Explorer
http://winscp.net/eng/download.php
tar
Compres/ uncompress utility files that are compressed with tar are called tarballs
tar -zxf filename
To uncompress a tar file to a directory of the same name in the root of the directory from were the command is executed
Text Editors
vi
http://unixhelp.ed.ac.uk/CGI/man-cgi?vi
vi /path/filename
Press Esc to activate window
! To edit
:wq to write to file and quit
:q to quit
nano
friendly for Windows admins
Commands at bottom of screen
Ctrl+O to write file
Ctrl+X to exit
Host file
/etc/hosts
Network restart
/etc/init.d/networking (stop/start/restart)
Ifconfig eth1 hw ether macaddress
Useful Commands
Press tab to auto complete filenames / paths
Cat /etc/sy <TAB> will complete sysconfig
To copy simply highlight the text with mouse and right click at the point you want to paste
Hold Shift + page up or page down to scroll through out put
This is useful when output from a command is more than a single screen full.
up or down curser key to cycle through previous commands
ls
Unix version of dir
ls -l – display content of a directory including permissions
Ls -lh same as above only file size in human friendly format (easier to read in Kb, Mb, Gb etc)
Permissions
http://www.freeos.com/articles/3127/
In the format w/xxx/yyy/zzz
The w denotes file/directory if its set to d its a directory
First group xxx are the permissions for the owner
Second group yyy are the permissions for the group
Third group zzz permissions for anyone
r – Read permission. Whether the file may be read. In the case of a directory, this would mean the ability to list the contents of the directory.
w – Write permission. Whether the file may be written to or modified. For a directory, this defines whether you can make any changes to the contents of the directory. If write permission is not set then you will not be able to delete, rename or create a file.
x – Execute permission. Whether the file may be executed. In the case of a directory, this attribute decides whether you have permission to enter, run a search through that directory or execute some program from that directory.
Executables
Unlike Windows based OS even if you are in the directory that contains an executable unless its in the path it will not run. In order to accommodate this you need to prefix the command with ./
Example
To run the ZXTM install navigate to the install directory e.g. /root/ZXTM_42R2_Linux-x86
The type ./zinstall
Display content of a file – e.g. Eth0 configuration (eth0 is primary NIC eth1 secondary etc )
cat /path/filename
Touch /path/filename to create an empty file of the name
ifconfig (like Ipconfig) http://unixhelp.ed.ac.uk/CGI/man-cgi?ifconfig
Ifconfig
clear – clear screen
(cls in windows command prompt)
Search from root for a file http://unixhelp.ed.ac.uk/CGI/man-cgi?find
find / -names filneame
e.g. Find / -name *eth0
Similar to above command displays paths containing filename
which
http://unixhelp.ed.ac.uk/CGI/man-cgi?which
which filename
Grep
http://unixhelp.ed.ac.uk/CGI/man-cgi?grep
Ps -ef | grep "search critira"
Ps -ef | grep sendmail
Display all sendmail processes running
Find a file then search the file for a specific value {} this replaces the current filename
find / -name index.html -exec grep -l "some value" {} \;
Redhat (RHEL) network interface configuration
Redhat Linux network interface names start with ethX. First Ethernet network interface name is eth0, second is eth1 and so on.
Login as a root user, use su – command:
$ su -
To list or display more information about network interface type command:
# ifconfig | less
To assign an IP address type following command:
# ifconfig eth0 192.168.1.1 up
To take down network interface type following command:
# ifconfig eth0 down
You can also type command setup and select network configuration from menu:
# setup
If you wish to configure network interface manually then you need to edit files stored in
/etc/sysconfig/network-scripts/ directory.
For example here is my sample /etc/sysconfig/network-scripts/ifcfg-eth0 file for eth0 network interface:
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=00:0F:EA:91:04:07
IPADDR=192.168.1.111
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet