IcyBlueTux

Tips and Examples: Ubuntu(Debian/GNU)-Linux Server, Bash, Vim


TABLE OF CONTENTSINDEXBOTTOM OF PAGE

Table of contents

ubuntu(debian/gnu)-linux and bash

vim

apache2

other

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

FTP-Servers: vsftpd, ProFTPd

NEEDS EDITING / NEEDS TO BE COMPLETED!

(see Wikipedia for information on these ftp servers)
(add short info, installation info, usage info)
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Get Info On Services Listening At Specific Network Address/Port

NEEDS EDITING / NEEDS TO BE COMPLETED!
Explain options.

> nmap -sV -n -v -P0 -p21 target_host_ip
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Get List Of Open Ports And Connected Services

NEEDS EDITING / NEEDS TO BE COMPLETED!
Explain options.

> netstat -tulpen
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Temporarily Change Network Settings

Set the ip-address and network mask ( replace ethX with the appropriate interface, and aaa.bbb.ccc.nnn with the desired host ip address ) :

> ifconfig ethX aaa.bbb.ccc.nnn netmask 255.255.255.0 up

Add a default gateway ( replace aaa.bbb.ccc.ddd with the ip address of the default gateway ) :

> route add default gw aaa.bbb.ccc.ddd

Add a nameserver temporarily ( replace rrr.sss.ttt.uuu with the address of a valid nameserver ) :

> echo "nameserver rrr.sss.ttt.uuu" | tee /etc/resolv.conf > /dev/null
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Ubuntu Server - Initial Login

Example:
Assuming that the name of the newly installed host is  host1234  and the name of the superuser entered during installation is  sume  ( a play with words for want of a better idea as an example name: assume or superuser + me )

Login with superuser  sume :

host1234 login: sume Enter the name of the superuser here, then press   Enter .
Password: Enter the superuser's password here, then press   Enter .
Note: the typed in password will not be displayed on screen!
   
sume@host1234:~$ The initial prompt will be similar to this. Remember: the standard linux prompt of the root user ends with  # , all others have  $  at the end.

See also: Logging In As User_X  and  Logging Out
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Ubuntu Server - Activate Root Account

This example builds on the previous  Ubuntu Server - Initial Login  example!
sume@host1234:~$ sudo passwd   Enter 
[sudo] password for sume: To ensure authorization for creating a root password enter the superuser password here, then press   Enter .
[sudo] password for UNIX: Enter the new password for root here, then press   Enter .
[sudo] repeat password for UNIX: To avoid typing errors reenter the new password for root here, then press   Enter .
  Note: the typed in passwords will not be displayed on screen!

... success message ...
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Logging In As User_X

General:
host_name login: user_x Enter the name of the user here, then press   Enter .
Password: Enter the user's password here, then press   Enter .
Note: the typed in password will not be displayed on screen!
   
user_x@host_name:~$ The initial prompt will be similar to this. Remember: the standard linux prompt of the root user ends with  # , all others have  $  at the end.
With the root user it will be:
host_name login: root Enter the user name root here, then press   Enter .
Password: Enter the password of the user root here, then press   Enter .
Note: the typed in password will not be displayed on screen!
   
root@host_name:~# The prompt will be similar to this. Remember: the standard linux prompt of the root user ends with  # .

See also:  Ubuntu Server - Initial Login ,  Ubuntu Server - Activate Root Account  and  Logging Out
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Logging Out

General:
user_x@host_name:~$ exit
With the root user it will be:
root@host_name:~# exit
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Change User

> su user_x
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Who Am I Logged In As?

> whoami
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Get various system infos

get linux kernel version:

> uname -r

or with some additional information about installed gcc versions etc:

> cat /proc/version

get ubuntu os info:

> lsb_release -a  or  --all
> lsb_release -i  or  --id
> lsb_release -d  or  --description
> lsb_release -r  or  --release
> lsb_release -c  or  --codename
> cat /etc/lsb-release

get ubuntu os short info:

> cat /etc/issue

motd - message of the day:

> cat /etc/motd  (might link to /var/run/motd)
> cat /etc/motd.tail 
> cat /var/run/motd  (regenerated on every boot from /etc/motd.tail - if this exists, otherwise (?)) (might link to /run/motd)
> cat /run/motd 

cpu information:

> cat /proc/cpuinfo

mounted ISO-9660 (CD-ROM) name

> volname
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Check For Running Processes, Logged On Users Etc.

> ps list of running tasks under current user or with options for all users - e.g. ps -elFy
> pstree   "tree" of running processes
> top     active list of running tasks and some system info - quit with q
> users   list of logged in users
> w       list of logged in users and on which terminal
> who     list of logged in users and on which terminal (not so informative as w)
> last    list of recently logged in users with times etc
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

List Of Opened Files

> lsof Lists all opened files
> lsof | grep somepattern Lists all opened files whose path/name contains the given pattern
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Get Folder Size

Source: http://askubuntu.com/questions/1224/how-can-i-determine-a-folders-size-from-the-command-line

> du -sh /path/to/folder

The  -s  is for summary (otherwise you'll get not only the size of the folder but also for everything in the folder separately), the  -h  is to get the numbers "human readable", e.g. get 140M instead of 143260 (size in KBytes) (by Marcel Stimberg: http://askubuntu.com/users/275/marcel-stimberg)

One more useful bit:

> du -h --max-depth=1 /path/to/folder  Will produce a list of all the folders in /path/to/folder and their sizes.

Trying to find the biggest?

> du --max-depth=1 /path/to/folder | sort -nk1  will organize the list from smallest to largest.  ( by Marco Ceppi: http://askubuntu.com/users/41/marco-ceppi )
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Get Disk Space Usage / Free Disk Space

Sources:
  http://askubuntu.com/questions/73160/how-do-i-find-the-amount-of-free-space-on-my-hard-drive
  df man page ( > man df )

> df
Some options:
> df -h to get the sizes in "human readable" form, e.g. get 140M instead of 143260; sizes are in KiB, MiB, GiB etc., i.e. using powers of 1024
> df -H same as the option  -h , but sizes are in KB, MB, GB etc., i.e. using powers of 1000
> df --total output grand total of disk space used / available at end of list
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

output number of colors terminal supports:

> tput colors
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

get last return code (error code)

> echo $?
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Navigating In Bash

Return current directory as string: pwd
Save current directory to stack and change directory: pushd someotherdirectory
Go to first directory on stack and remove from stack: popd
List directories on stack: dirs
Rotate stack n times: pushd +n
Remove entry from stack: popd +0

Change to home directory: cd
Change to last directory: cd -

#### Can a Bash script tell what directory it's stored in?
#### 20121119-190841w-Mo from <http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in>

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

Or, to get the dereferenced path (all directory symlinks resolved), do this:

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

This last one will work with any combination of aliases, source, bash -c, symlinks, etc.
share|improve this answer

edited Jun 6 at 8:44

community wiki

6 revs, 6 users 36%
Frank Szczerba
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Packing / Unpacking Files

.tar.gz/.tgz , .tar.bz2, .zip

> tar xzfv somefile.tar.gz  : Unpack a *.tar.gz file
tar (unix tool for writing / reading archives to / from tape)
options:
 -f write / read to / from a file
 -z pack / unpack using GNU zip (gzip)
 -j pack / unpack using bzip2 (ext: .tar.bz2 - better compression than gzip)
 -c create
 -x extract
 -v verbose
 -t test archive

> gzip -dc somearchive.tar.gz | tar xfv -
> bzip2 somefile1
> bunzip2 somearchive.bz2
> tar cfvj somearchive.tar.bz2 [somedirectory1] [somedirectory2] [somefile1] [somefile2] ...
> tar xfvj somearchive.tar.bz2
> zip somearchive.zip [somefile1] [somefile2] ...
> zip -r somearchive.zip [somedirectory1] [somedirectory2] ...
> unzip -l somearchive.zip (list archive)
> unzip somearchive.zip

How to tar a list of files

from http://www.nixtips.net/how-to-tar-a-list-of-files/
Published on 29/03/2010 by fabio in bash, linux


If you want to tar multiple files you must write a file containing a list of files to backup and then use one of these commands:
> cat listoffiles.txt | xargs tar -czvf yourbackupname.tgz

or:
> tar -czvf yourbackupname.tgz $(cat listoffiles.txt)

A more complex example using piping

In the following example we look for all directories beginning with log, then pipe the list to egrep to get a list of only those directories which are called log, logs or logging, then piping this new list to xargs, which passes this list as arguments to tar for making an archive of the listed directories. The archive is named using the following format: backup_logs_ + present_date_and_time + extension:

> find / -type d -name log\* | egrep "log(s|ging)?$" | xargs tar -czvf backup_logs_`date "+%Y%m%d-%H%M%S"`.tar.gz

Explanation:

First segment of pipe : using find search starting from system root ( / ), search for directories only ( -type d ) beginning with "log" ( -name log\* ) and make a list of all found directories. Note that the wildcard asterisk needs to be escaped!

Second segment of pipe : grep the list passed from find using extended regex ("grep -E" or "egrep") and search for lines containing log, logs or logging (in the pattern "log(s|ging)?$" the part contained in brackets may occur zero or one time only "()?", the "|" within the brackets means either use that which precedes or that which follows it. The "$" sign at the end of the pattern denotes end of line, meaning that no letter may follow (to avoid including lines that may contain directories named "logo", "logsd" etc.

Third segment of pipe : xargs receives the list passed by grep and hands this list over to tar as arguments. tar creates a new compressed file with a name similar to  backup_logs_20121210-094512.tar.gz, using the current date and time. The date command, together with all its options and arguments, needs to be bracketed in ` ` ( accent graves ). The date format used may not contain any characters which cannot be used in a linux file name!
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Find And Replace some_string In File(s) Using find And sed

In a single file

> sed -i 's/<some_string>/<new_string>' /path_to_file/file_name

In several files

> find some_path -type f -exec sed -i 's/some_string/new_string/g' {} \;

This would search for all files ( -type f ) in  some_path  and all its subdirectories recursively, and replace all found occurrences of  some_string  with  new_string !
Use this type of search and replace with the greatest care, as such a command can easily destroy a whole system, especially if using it with root privileges!
By using -maxdepth 1 the search would be limited to the directory designated by some_path and not recurse into subdirectories!
Examples
Replace all occurrences of  /icon  with  icon  in all files in the current folder which end in .html  ( note that the special character / contained in the first string  /icon  has to be "escaped" using \ ):
> find . -maxdepth 1 -iname "*.html" -exec sed -i -e "s/\/icon/icon/g" {} \;

Replace all occurrences of  my-example-site.com  with  <a href="http://my-example-site.com/">my-example-site.com</a>  in all files in the current folder which end in .html  ( note that some special characters have to be "escaped" using \ ):
> find . -maxdepth 1 -iname "*.html" -exec sed -i -e "s/my-example-site\.com/\<a href=\"http\:\/\/my-example-site\.com\/\"\>my-example-site\.com\<\/a\>/g" {} \;
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Search For some_string In Files With grep

> grep "some_string" * search all (non-hidden) files in current directory and output all lines found containing some_string
> grep "some_string" .* search all hidden files ( those beginning with a period )
> grep "some_string" * .* search both visible and hidden files
> grep -r "some_string" * search also in subdirectories recursively
> grep -i "some_string" * ignore case
> grep -l "some_string" * only list the names of files containing some_string

Example

The following example will:
> grep -lr --exclude-dir="." --exclude-dir=".." "somestring" /somedir/* /somedir/.*
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Updating / Upgrading

Update package list (resynchronize the package index files from their sources):
The file  /etc/apt/sources.list  contains the locations, from which the indexes of available packages can be fetched.

> apt-get update

Upgrade packages:
> apt-get upgrade

Upgrade system (use this, when upon upgrading with "apt-get upgrade" an error is returned "The following packages have been kept back:"):
Option  -u : Show upgraded packages.

> apt-get dist-upgrade -u

or:
> aptitude full-upgrade

Search for kernel version (optional):
> apt-cache search linux-headers-$(uname -r)

Install linux-header package under Debian or Ubuntu Linux:
> apt-get install linux-headers-$(uname -r)

Remove packages that were automatically installed and are no longer required:
> apt-get autoremove

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Upgrade Ubuntu Release

> do-release-upgrade
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Suppress "New Release Available" Login-Message For Non-LTS Versions

Source: http://askubuntu.com/questions/205459/how-do-i-suppress-the-new-release-12-10-available-message

The configuration file  /etc/update-manager/release-upgrades  controls for which updates a notification will be generated.
The script  /usr/lib/update-manager/release-upgrade-motd  generates the "Update available" message.
The problem is that the script caches the message, thus changing the settings in the above mentioned configuration file doesn't get rid of it.
Solution:
1. Edit  /etc/update-manager/release-upgrades  and make sure the prompt-entry reads:

Prompt=lts

2. Delete the cache file:

> rm /var/lib/update-notifier/release-upgrade-available
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Remove Old Kernel Packages

Examples

Sources:
http://tuxtweaks.com/2010/10/remove-old-kernels-in-ubuntu-with-one-command/
http://tuxtweaks.com/2009/12/remove-old-kernels-in-ubuntu/
http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script

The following command will remove all installed kernel versions except the current one
> dpkg -l linux-* | awk '/^ii/{ print $2 }' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -v '\(\-37\)\|\(\-39\)' | xargs apt-get --dry-run purge

( Note: replace "--dry-run" with "-y" ( = presume yes ) so the line actually purges the non-current kernel packages! )
The following script will remove the oldest installed package from the system, if there are more than 3 kernel versions installed
#! /bin/bash
# Copyleft 2013-03-27 17:11+0100 We by me ( adapted from the above mentioned sources )
# get the current kernel version
currentKernel=`uname -r`
# set the minimum number of kernels that should be kept on the system
minNumberOfKernels=3
echo
echo "Script for removing the oldest installed kernel package(s)"
echo
echo "Currently running: $currentKernel"
echo
echo "The following kernel images exist in /boot :"
ls /boot | grep vmlinuz | cut -d'-' -f2,3
echo
# get the total number of installed kernels
numberOfKernels=`ls /boot | grep vmlinuz | wc -l`
echo "Number of installed kernels: $numberOfKernels"
echo
# if the number of installed kernels is greater than minimum number of kernels (set above), then do the following:
if [ $numberOfKernels -gt $minNumberOfKernels ]; then
# get list of installed kernels and choose the first entry
oldestKernel=`ls /boot | grep vmlinuz | cut -d'-' -f2,3 | head -1`
# get list of kernel package(s) to be removed
removeKernelPackages=`dpkg -l linux-* | awk '/^ii/ { print $2 }' | grep $oldestKernel`
# if the variable oldestKernel is not equal to the variable currentKernel then do the following:
if [ $oldestKernel != $currentKernel ]; then
echo "Do you want to remove the following old kernel package(s):"
echo ">>"
echo "$removeKernelPackages"
echo "<<"
echo
# read exactly 1 char into variable yn and continue
read -s -n 1 -p "Y/N:" yn
echo
case $yn in
# if yn has the value Y or y then do the following:
[Yy]* )
echo "Removing the kernel package(s)"
echo ">>"
echo "$removeKernelPackages"
echo "<<"
echo
echo "$removeKernelPackages" | xargs apt-get -y purge
;;
# if yn has any other value than Y or y, then give the following error message before exiting the script:
* )
echo "The kernel package(s)"
echo ">>"
echo "$removeKernelPackages"
echo "<<"
echo "were not removed!"
echo
;;
esac
# else if oldestKernel is the same as currentKernel then give the following error message before exiting script:
else
echo "The current (running) kernel package(s)"
echo ">>"
echo "$removeKernelPackages"
echo "<<"
echo "will not be removed, as this would destroy the system!"
echo
fi
# else if number of installed kernels is equal to or less than minimum number of kernels (set above) then give the following error message before exiting script:
else
echo "This script will only offer removal of kernel package(s), if the number of installed kernels is greater than $minNumberOfKernels!"
fi

The script can be downloaded via the following link:  remove_oldest_kernel_package.sh
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Ubuntu: Installing PPA Packages

PPA (Personal Package Archive) packages are offered by third parties and not tested by the Ubuntu team. Installing them is "at your own risk".

PPA packets are offered via the Ubuntu site using the following format for the source: ppa:PPA-USER/PPA-NAME.

Prerequisite: check whether add-apt-repository is installed:

> add-apt-repository

If not installed, the following error message is shown:
The program 'add-apt-repository' is currently not installed. You can install it by typing: apt-get install python-software-properties

> apt-get install python-software-properties

Now the PPA source must first be added to the sources list:

> add-apt-repository ppa:PPA-PROVIDER/PPA-NAME

Then the list of available packages needs to be updated:

> apt-get update

Now the PPA packet can be installed with:

> apt-get install PACKET-NAME
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Install cdrtools

From the "Personal Package Archive" of Brandon Snider ( https://launchpad.net/~brandonsnider/+archive/cdrtools ).

> add-apt-repository ppa:brandonsnider/cdrtools

> apt-get update

> apt-get install

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Change Path Of System Directories

Source: http://www.rootforum.org/forum/viewtopic.php?f=110&t=48474

NEEDS EDITING / NEEDS TO BE COMPLETED!

> mount --bind /path/to/some/dir /otherhd/path/to/some/other/dir

or:

> ln -s /path/to/some/dir /otherhd/path/to/some/other/dir
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Vim Configuration File .vimrc

In your home directory ( ~/ ) look for a hidden file  .vimrc  - if it doesn't exist, create it.
Edit: ~/.vimrc

Some settings which can be added to  .vimrc :

:set numberwidth=6 Width / columns reserved for line numbers.
:set number Switch on numbering for lines. Switch off line numbering with  :set nonumber
:set nowrap Text will not be wrapped at screen width. By default text will be wrapped.
:set tabstop=4 Tabstop width.
:set autoindent Switch on auto-indenting. Switch off auto-indenting with  :set noautoindent
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Some vim commands

  Esc   exit any of the following modes ( INSERT / REPLACE / VISUAL / COMMAND )
  Ins   toggle insert / replace ( overwrite ) mode ( shows -- INSERT -- or -- REPLACE -- at bottom left )
  v   enter visual mode for marking text ( shows -- VISUAL -- at bottom left )
  Shift   V  enter visual mode for marking whole lines ( shows -- VISUAL LINE -- at bottom left )
  y   yank ( copy ) marked text to clipboard
  p   paste clipboard content after cursor
  Shift   P  paste clipboard content before cursor
  :   enter command mode ( shows : at bottom left )
:w write to file ( save )
:wq write to file ( save ) and quit vim
:q quit vim
:q! force quitting vim ( without saving )
:set all show list of set options
:/xyz search for string "xyz"
  n   search for next occurance of string "xyz"
  Shift   N   search for previous occurance of string "xyz"
:%s/xyz/abc/gcI search for occurances of string "xyz" and replace with string "abc"
Options: % = all lines, g = global = all occurances in a line, c = ask for confirmation, I = ignore case, i = don't ignore case
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Copy And Paste Between Two Instances Of Vim

After marking and copying text, open a new file buffer with ( as an example ) the name "transfer.text":

:e ~/transfer.text

Paste the copied text to the new buffer with  p  

Write the new buffer:

:w

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Disable Blanking / Deactivation Of Screen After A Set Period

Edit: /etc/default/grub

Add the option  consoleblank=0  to the key  GRUB_CMDLINE_LINUX=" "

GRUB_CMDLINE_LINE="consoleblank=0 vga=0x316"

If more than one option is added to  GRUB_CMDLINE_LINUX=" ", the options need to be seperated by a space character!

After making any changes to  /etc/default/grub  the following needs to be run to update grub's internal configuration file:

> update-grub

Check and edit the following commands:
> setterm -blank 0
> setterm -powersave off
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Display Grub Menu At Startup

Edit: /etc/default/grub

Change the keys  GRUB_HIDDEN_TIMEOUT  and  GRUB_TIMEOUT  to look as follows:

GRUB_HIDDEN_TIMEOUT=
GRUB_TIMEOUT=8

After making any changes to  /etc/default/grub  the following needs to be run to update grub's internal configuration file:

> update-grub
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Change Terminal Screen Resolution

Edit: /etc/default/grub

Add the desired resolution from the table below to the key  GRUB_CMDLINE_LINE :

Colors \ Size640x480800x6001024x7681280x1024
2560x3010x3030x3050x307
32k0x3100x3130x3160x319
64k0x3110x3140x3170x31A
16M0x3120x3150x3180x31B

Example:
GRUB_CMDLINE_LINE="consoleblank=0 vga=0x316"

If more than one option is added to  GRUB_CMDLINE_LINUX=" ", the options need to be seperated by a space character!

After making any changes to  /etc/default/grub  the following needs to be run to update grub's internal configuration file:

> update-grub
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Search For And Kill Zombie Processes

> ps aux | awk '{ print $8 " " $2 }' | grep -w Z
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

VirtualBox Guest-Additions - Add shared folder mountpoint

> mount -t vboxsf share mountpoint (didn't find)

but using the following worked:

> apt-get install virtualbox

Reboot after installation

----
check the following sometime:
VBoxManage controlvm "MACHINE NAME" setvideomodehint WIDTH HEIGHT BPP
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Shutting Down (Powering Off) or Rebooting (Restarting)

Shut down
> shutdown -P now : -P = power off

or the hardcore:

> init 0          : enter runlevel 0 (switch off) (pros / cons?)
Reboot
> shutdown -r now : -r = reboot / restart
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Ubuntu firewall

> ufw disable : Disable firewall
> ufw enable  : Enable firewall

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

OpenSSH

> apt-get install openssh-client openssh-server

Copy files between machines securely with  scp :

> scp [[user@]hostname.domain.tld:]file1

Or log in to remote machine via  ssh :

> ssh [user@]hostname.domain.tld [command]  ( using DNS of remote machine )

or:

> ssh [user@]nnn.nnn.nnn.nnn [command]  ( using IP address of remote machine )

You will be prompted for the password of "user" - if no user is given, then the root user is implied!

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Kill An Unresponsive SSH Session

Source: http://unix.stackexchange.com/questions/2919/kill-an-unresponsive-ssh-session-without-closing-the-terminal

Enter the following three keys in succession:   Enter   ~   . 
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

OpenSSH File System

Install the package sshfs:
> apt-get install sshfs
Mount a remote machine into the local file system:
> sshfs [user@]hostname.domain.tld:[dir] mountpoint
Examples:
> sshfs root@x1234567.xyzserver.net:/ /media/xyzremote  ( mount root directory of remote machine: / = root directory )
> sshfs root@x1234567.xyzserver.net:/var/www /media/xyzremote  ( mount directory /var/www of remote machine )
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Reset unreadable terminal

Source: http://forum.ivorde.ro/normalizing-terminal-prompt-or-putty-prompt-after-catting-a-binary-file-t115.html by debuser

Some binaries or some unexpected command output can contain a control sequence which can cause a terminal to interpret it as changing the character set. That's why the prompt becomes unreadable and when keys are pressed, unexpected symbols appear on the screen. To fix this, there are a few possible solutions:

> echo -e '\017'

or:

> reset

or:

> stty sane
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Change Time Zone

Source: http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/

The current time zone is saved in the file /etc/timezone . It can be viewed with:

> cat /etc/timezone

Issue the following command to change the current time zone:

> dpkg-reconfigure tzdata

A list of geographic areas / regions will appear. Select the desired geographic area / region and press   ENTER   ( UTC and GMT can be found under Etc ).

In the next list select the city / region( or UTC / GMT ) corresponding to the desired time zone and press   ENTER  .

The selected time zone will be set. Now cron needs to be restarted so it will accept the changes:

> service cron restart

alternately:

> /etc/init.d/cron stop
> /etc/init.d/cron start

or in newer Ubuntu releases, where cron has been converted to an Upstart job:

> stop cron
> start cron
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Synchronize Time With NTP

The following information ( including parts of the text ) is from:
    https://help.ubuntu.com/8.04/serverguide/NTP.html
    http://www.pool.ntp.org/en/use.html

Important for virtual machines:
Setting the host's time using the following methods applies to the operating system of the physical machine only!
Operating systems on virtual machines are guest operating systems. They get their time from the underlying physical machine.
To set the time of the physical machine via NTP, use the appropriate methods for the host operating system.

Using ntpdate

Ubuntu comes with  ntpdate  as standard, and will run it once at boot time to set up the host's time using Ubuntu's NTP server. However, a server's clock is likely to drift considerably between reboots, so it makes sense to correct the time occasionally. The easiest way to do this is to get  cron  to run  ntpdate  every day.

To accomplish this, as root user create a file  /etc/cron.daily/ntpdate  containing the following line:

ntpdate ntp.ubuntu.com

As this file needs to be executable, change the permissions as follows:

> chmod 755 /etc/cron.daily/ntpdate

Using ntpd

NEEDS EDITING / NEEDS TO BE COMPLETED!

> xxx

or:

> xxx
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Apache2: Infos

Version info

Source: http://ubuntuforums.org/showthread.php?t=1245684

> apache2 -v

or:

> apache2ctl status | grep Version

Status info

> apache2ctl status

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Apache2: Control

Apache2: List Of Compiled In Modules

> apache2ctl -l

or:

> apache2 -l

Apache2: List Loaded Modules

> apache2ctl -M

or:

> apache2ctl -t -D DUMP_MODULES
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Apache2: Enable Modules

Get List Of Available Modules

> a2enmod

A list of modules that can be enabled will be displayed and a2enmod will wait for a choice to be made. To quit, don't type anything and simply press   Enter 

All available modules that can be enabled are stored in  /usr/lib/apache2/modules/  and can therefore also be listed using  ls :

> ls /usr/lib/apache2/modules/

Enable Specific Module

> a2enmod module_name

Enable Several Modules Using Wildcards

For example, enable all modules beginning with dav:

> a2enmod dav*  ( Added here from description but not tested! )

Restart the apache2 webserver after enabling any modules:

> service apache2 restart
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Apache2: Disable Modules

Get List Of Loaded Modules Which Can Be Disabled

> a2dismod

A list of enabled modules will be displayed and a2dismod will wait for a choice to be made. To quit, don't type anything and simply press   Enter 

A list of all loaded modules can be gotten with apache2ctl

Disable Specific Module

> a2dismod module_name

Disable Several Modules Using Wildcards

For example, disable all modules beginning with dav:

> a2dismod dav* ( Added here from description but not tested! )

Restart the apache2 webserver after disabling any modules:

> service apache2 restart
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

WebDAV On Ubuntu Server With Plesk Penal And Apache2 Webserver

Source: http://www.codarbyte.de/2011/01/webdav-in-plesk-10-0-1-aktivieren-eine-alternative-und-eigene-idisk/

To use WebDAV the following apache2 modules are needed:

    dav
    dav_fs

Check by listing the loaded modules:
> apache2ctl -M

If they aren't loaded, enable them:
> a2enmod dav
> a2enmod dav_fs

Restart the apache2 webserver:
> service apache2 restart

Activating WebDAV for a specifig site

Let's say, we have a site called  my-example-site.com. On this site, WebDAV is to be activated for a subdirectory called "share".

First, navigate to the httpdocs directory of my-example-site.com and there create the directory "share":
> cd /var/www/vhosts/my-example-site.com/httpdocs/
> makedir share

The apache2 webserver needs to have full read / write access to this subdirectory, which is ensured by giving the webserver ownership of "share":
> chown -R www-data:www-data /var/www/vhosts/my-example-site.com/httpdocs/share

Now, edit the file  /var/www/vhosts/my-example-site.com/conf/vhost.conf  ( if the file  vhost.conf  doesn't exist, then it needs to be created ), and add the following lines:

<Directory /var/www/vhosts/my-example-site.com/httpdocs/share>
    DAV on
</Directory>


Note: if the httpdocs files do not reside in the standard path, then the  my-example-site.com/httpdocs  part needs to be replaced with the correct path!

Note: After saving the vhost.conf file the configuration files need to be reloaded, so that Plesk Penal and the apache2 webserver are aware of the changes:

> /usr/local/psa/admin/sbin/websrvmng -a  ( obsolate - use httpdmng instead )

> /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

Now try to connect to the server / domain via WebDAV. On a Microsoft® Windows® 7 system open the Windows® explorer ( not Internet Explorer® ), scroll down to and right click on Network and in the context menu choose "Connect to network drive...". Now choose the drive letter to which the WebDAV directory should be mapped to, then enter the complete address to the server in the directory field ( e.g.: https://my-example-site.com ). If all went well, a requester for username and password will open, and after the correct entries the WebDAV-directory will be available under the chosen drive letter.
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Index

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Notes And Disclaimer

NOTES:

Specific terminal input / output will be displayed in  this script .
To indicate the terminal prompt in short form and for readability the  >  symbol has been used as an alias! Remember: the standard linux prompt of the root user ends with  # , all others have  $  at the end.
Keyboard keys are depicted as:  Key   - Examples would be:   Esc     Enter     A 


IMPORTANT NOTICE AND PESONAL DISCLAIMER:

The information contained on this page is a compilation from various sources on the internet or the linux man pages. Much of it is "copy and paste", and at best  I  have changed some formulations, or added some explanations. Basically this page has been compiled by  me  for my own reference. To the best of my knowledge all sources were "open-source". Should  I  be mistaken pertaining to some particular information included on this page, please inform  me, and  I  will change or remove it!  I  only started adding references regularly when  I  decided to put this page online ( mainly for personal accessibility ).

This page is ongoing work. It will never be complete! Things will just be added to it, corrected, improved or removed from time to time. If you wish, you are welcome to use the information contained on this page, but remember, you do so at your own risk. If something is unclear, it is your own responsibility to do further research. I cannot be held responsible for any damages which occurred due to the purported use of any information on this page.

Positive criticism, such as suggestions for improvements and corrections, are always welcome! Indeed, if you wish to actively help me improve this page, you are welcome to  contact me. Negative criticism of the type "this page is hogwash" is not helpful and just a waste of time - yours and mine!

This page is open source. You may copy it in whole or in part and alter / use the copy in any way you like, provided you do  not  claim that the altered copy is my original work ( I cannot be held responsible for your alterations ), and also, that you will  not  claim to yourself be the original author of the compilation! It would be fair (and nice) if you referenced this site as the original compilation or  me  as the original author of this compilation, but this is not a requirement.

This page is scripted using HTML5 and CSS3 code and has been intentionally kept "monolithic" to make it easy to download for offline reference and editing. It consists of only three ( relevant ) files, itself under the name "index.html" as well as   IcyBlueTuxR_60x72.png  and a  16x16 pixels icon  for the graphics. All CSS code is contained in the page's head. See also  Attribution And Information On The IcyBlueTux  for additional information and resources.

LEGAL DISCLAIMER (required by German law):

Limitation of liability for internal content

The content of our website has been compiled with meticulous care and to the best of our knowledge. However, we cannot assume any liability for the up-to-dateness, completeness or accuracy of any of the pages.

Pursuant to section 7, para. 1 of the TMG (Telemediengesetz - Tele Media Act by German law), we as service providers are liable for our own content on these pages in accordance with general laws. However, pursuant to sections 8 to 10 of the TMG, we as service providers are not under obligation to monitor external information provided or stored on our website. Once we have become aware of a specific infringement of the law, we will immediately remove the content in question. Any liability concerning this matter can only be assumed from the point in time at which the infringement becomes known to us.

Limitation of liability for external links

Our website contains links to the websites of third parties ("external links"). As the content of these websites is not under our control, we cannot assume any liability for such external content. In all cases, the provider of information of the linked websites is liable for the content and accuracy of the information provided. At the point in time when the links were placed, no infringements of the law were recognisable to us. As soon as an infringement of the law becomes known to us, we will immediately remove the link in question.

Copyright

The content and works published on this website are governed by the copyright laws of Germany. Any duplication, processing, distribution or any form of utilisation beyond the scope of copyright law shall require the prior written consent of the author or authors in question.

Data protection

A visit to our website can result in the storage on our server of information about the access (date, time, page accessed). This does not represent any analysis of personal data (e.g., name, address or e-mail address). If personal data are collected, this only occurs - to the extent possible - with the prior consent of the user of the website. Any forwarding of the data to third parties without the express consent of the user shall not take place.

We would like to expressly point out that the transmission of data via the Internet (e.g., by e-mail) can offer security vulnerabilities. It is therefore impossible to safeguard the data completely against access by third parties. We cannot assume any liability for damages arising as a result of such security vulnerabilities.

The use by third parties of all published contact details for the purpose of advertising is expressly excluded. We reserve the right to take legal steps in the case of the unsolicited sending of advertising information; e.g., by means of spam mail.

Source: Rose & Partner LLP, provided by Open-Times.com
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

Contact

Via e-mail: azuraster@gmx.net
TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

IcyBlueTux

Attribution And Information On The IcyBlueTux

TOP OF PAGETABLE OF CONTENTSINDEXBOTTOM OF PAGE

This page was last updated: 2025-07-01 22:24:30 Tu UTC+0000