10 mental blocks keeping you from being a kick-ass sysadmin

Ok, it’s actually an article about 10 Mental Blocks to Creative Thinking but isn’t creative thinking a huge part of being a kick-ass sysadmin? Here’s what I thought of when I read each point, but I highly recommend that you read the whole article and look for ways it applies to you.

In terms of what mindset you should be in:

  1. There is almost always more than one right answer.
  2. Don’t be so rigid with your logic that you become blind to other possibilities.
  3. Always question everything – “why” or “why not”.
  4. Always ask “what if” and explore ideas even if they don’t seem feasible on the surface.
  5. Make time to play. You’ll be amazed at what problems you solve when you’re not at your desk.
  6. Never say “That’s not part of my job” and explore and learn about as much as you can.
  7. Try to think about things differently than everyone else at the table is.
  8. There is no black and white, only gray, and that’s ok.
  9. It’s ok to be wrong and you will be. It’s ok to make mistakes and you will. Learn from it.
  10. If you think you can’t do it, then you can’t. You won’t really know unless you try.

Repairing MySQL tables that will not open.

This should be handled on a case by case basis, but if you are using the default MySQL table type of MyISAM (which is the default storage engine unless changed or specified differently) here are a few options:

  1. The myisamchk utility can be run from a command line to checks, repairs, or optimizes tables. It is normally run while the database is not running. For more information about myisamchk visit the MySQL website.
  2. mysqlcheck is similar in function to myisamchk, but can be run while the database is running. For more information about
    mysqlcheck visit the MySQL website.
  3. If you login to the database, you can also run sql commands that might fix your problem.
    Examples:
    mysql> optimize table your-tablename;
    mysql> analyze table your-tablename;
    mysql> repair table your-tablename;

    For more information about
    table maintenance SQL visit the MySQL website.
  4. If you are getting MySQL error numbers and are not sure what they are. From a command line you can use the perror utility to lookup errors. For more info on perror visit the MySQL website.
    Examples:
    shell> perror 13 64
    Error code 13: Permission denied
    Error code 64: Machine is not on the network

How to change the default port for Plesk

It is not recommended to change the default Plesk port because it can break Plesk integration with other programs (like Plesk Expand or DrWeb).

Linux

To change the port Plesk listens on you will need to edit /usr/local/psa/admin/conf/httpsd.conf file and change the following directives to list the port you want Plesk to listen on:

Listen 8443
Port 8443
<VirtualHost *:8443>

You will need to restart Plesk afterwards and update the hardware object in the SoftLayer portal with the new port (Hardware > Click on Server name > Password Update / History)
Plesk cannot listen on any of the ports used for common services (21, 22, 23, 25, 53, 80, 110, 443 etc..).

Windows

Most Plesk installs will be using Apache by default. You will want to edit the Apache configuration file C:\Program Files\SWsoft\Plesk\admin\conf\httpd.conf

1.) Change the following line to list the port number you want Plesk to listen on
Listen 8443

2.) Restart Plesk Control Panel
You will need to restart Plesk afterwards and update the hardware object in the SoftLayer portal with the new port (Hardware > Click on Server name > Password Update / History)

Restarting Mail Enable through Plesk (Windows)

In order to restart the Mail server [Mail Enable], please use these steps. 

1) Login To Remote Desktop >> “Plesk Services Monitor” [ Right side in the task bar] >> Check the box “Mail Server” >> Click on Restart.

OR

2) Login To Remote Desktop >> Start >> Run >> type ” services.msc ”

From here, you have restart the Mail Enable [ Mail Server] services such as:
Mail Enable List Connector
Mail Enable Mail Transfer Agent
Mail Enable POP service
Mail Enable PostOffice Connector
Mail Enable SMTP Connector

Right Click on it and press Restart.

Service/Daemon Management

restarting/stopping/starting a service

On any init.d based linux distro you can restart a service with the following…

/etc/init.d/serviceName restart

You may replace ‘restart’ with ’stop’ or ’start’ (and in some cases ’status’).
Forcefully stopping a service

killall processName

Killing on instance of a service

kill pid

The pid can be gathered by either top or ps

Disabling/adding/listing services

chkconfig –list

displays all the services and if they are set to run in different runlevels
use the –del daemonName to remove a service or –add daemonName to add one

 chkconfig [–level <levels>] <name> <on|off|reset>

 eg.  chkconfig –level 3 httpd on

This will set the httpd to ON on run level 3.

setting a program to run at startup

Add a line executing the command at the end of /etc/rc.local

File Manipulation
Editing Text Files

vi is by far the best text editor but has a learning curve to it. If you want simplicity use nano
display a text file from the command line

cat filename

or

more filename

Display the last few lines of a text file

tail filename

or you can display the last 50 lines of a file with…

tail -50 filename

or you can display lines as they are written to a file (or follow) with the following: (UBER useful for log files)

tail -f filename

copy a file

cp filename destination

move a file

mv filename destination

delete a file

rm -f filename : removes the file. -f makes it so it doesn’t ask you if you are sure

Displaying the differences between two files

diff file1 file2

Installing crap

On redhat derived systems (RedHat, Fedora, CentOS, Rocks, Mandrake, etc) yum is your package manager.

yum install appname : installs the application from the remote yum repository

yum search appname : does a search on the repository for a given program

yum remove appname : uninstalls an app

use ‘man yum’ for a complete list

Archives

tar.gz or .tgz is the most common compression found in the linux world. that is tared (Tape ARchive) and gziped. Sometimes called “tar balls”.

tar -xzf file.tgz : will X’trackt a tar/gzip file.

tar -czf myfile.tgz someDir : will create a tar and gziped archive of the given directory

gunzip : un gzips a file

unzip : unzips a .zip file

File Permissions

Listing Permissions

ls -al will display all files in a list with their owners and permissions

-rw-r–r– 1 irq13 irq13 1006 Jan 24 10:16 .bashrc

Now to break down the above example…

-rw-r–r– is the permissions area.

The first – would be d if the item is directory, otherwise it will be -.

The second 3 dashes indicate read/write/execute for the owner,
the second is r/w/x for the group and third is r/w/x for everyone else.

The next number is the inodes associated with the file. This isn’t important for you to know the basics

Next when it says irq13 irq13 that indicates the owner of the files name group
Changing ownership of a file

chown username:groupname file
Changing permissions of a file

chmod XXX filename

chmod uses a numeric system for assigning ownership.
XXX represents 3 numbers.
The first is the permissions applied to the owning user, 2nd is group, 3rd is everyone else.

1: execute 2: write 3: write & execute 4: read 5: read & execute 6: read & write 7: read, write & execute

Remember that 777 is only to be used as a trouble shooting step to rule fs permissions out.

NEVER leave a dir as 777. Its useful to do ‘ls -alh * > perm_capture.txt’ before messing with a file.

That way you can restore its original permissions.
Attributes

Files also have attributes, similar to the ones found in the windows world.

lsattr filename : Lists the attributes of a file or directory

chattr +-=[ASacDdIijsTtu] filename

to add an attribute use + to remove use –

File Attributes

append only (a)
compressed (c)
no dump (d)
immutable (i)
data journaling (j)
secure deletion (s)
no tail-merging (t)
undeletable (u)
no atime updates (A)
synchronous directory updates (D)
syn-chronous updates (S)
top of directory hierarchy (T)

Use man chattr for an explanation of each attribute
launching scripts and bins

* If an executable file is in your path you may simply type its name from anywhere on the system and it will execute.
* To see what your path is type ‘path’
* To execute a file in the current directory type “./filename
* To execute a file it must have execute permissions for either your username or a group you belong to.

Additional command operators

ps | grep ssh — only display lines that contain ssh

; used to “stack commands” or issue multiple commands on 1 line. cd ..; ls

& puts a command in the background. Will let you know when the command is finished

> write what is displayed on the screen from a given command to a text file ls -alh /root > /root/myRoot.txt

>>

appends screen output to an existing file

Basic commands

* whoami : displays current user
* top : displays the top cpu/memory eaters and system load.. like task manager on windows
* ps : displays all processes running.. ps aux is the most useful way to run it
* wall “some text” : sends a broadcast message to all logged on users
* man program : displays the ‘man page’ or manual for a given program. Use space bar to page down and q to exit
* program -h : displays the help for a given program, briefer than man
* du -sh dirName : Displays the total size of a directory recursively
* df -kh : displays total and available storage on all partitions for the system
* locate filename : finds ware a program or file is located on the system
* w : displays who is ssh’ed or logged in.
* watch -n seconds filename : will execute a file every n seconds. Useful to watch who is online, watch -n 3 w
* wget http://somesite.com/somefile : gets a file via ftp, rsync, http, etc from a remote host.
* netstat : displays all listening ports and active connections
* ifconfig : used for listing network interface info and setting it
* clear : clears the terminal
* md5sum filename : displays the md5 checksum of the given file