Wednesday, February 24, 2016

UNIX/Linux/Ubuntu system administration DAY 08

I. Grep tool

1. grep sshd /var/log/* find files in which the string sshd (the SSH daemon's name) appears
2. grep vboxsf /etc/group :check vboxsf group exists

II. Apache/PHP/MySQL

1. sudo /etc/init.d/apache2 restart

III. Networking

1. Fn F2 to enable wireless interface
2. tracepath 192.168.1.20 :display network path to another host

IV. Manage Files and Files Systems

1. df -h -l :display free diskspace
2. du -h ~ :-display disk usage of the current user
3. umount /media/cdrom :unmount CD-ROM drive
4. umask u=rwx, g=r, o= :set default permissions assigned to newly created files
5. tar -zcf myfile.tar.gz my_difrectory :combine files into 1 large file and use gzip to compress it
6. zip -r myfile.zip my_directory :create a window-compatible zip file
7. tar xjvf archive.tar.bz2 :extract the contents of archive.tar.bz2
8. tar cjvf achive.tar.bz2 my_directory :compress my_directory
9. tar xzvf archive.tar.gz :extract the gz file

V. Kernel related commands

1. dmseg :display kernel message log

VI. Ubuntu Command Line and GUI modes

1. Ctrl+Alt+F2 : command line mode
2. Ctrl+Alt+F7 :GUI mode

VII. Find tool

1. find . > list_of_files.txt :creates a list of files and save it into list_of_files.txt.
2. find / -size +1M -user core : find all files owned by the user core that are bigger than 1M bytes.
3.  find / -size +1M -user core -print | xargs ls -sd : find all files owned by the user core that are bigger than 1M bytes and show the sizes of the files.

VIII. Ps tool

1. ps uawx | head :shows the 10 processes using most of the CPU cycles.
2. ps aux | grep apt :display all apt processes
3. kill process_number :terminate a PID
4. kill -9 process_number :terminate a PID
5. ps -ef :display all running processes in detail

IX. Manage Users and Groups

1. useradd -m username :add a user and create a home directory for it
2. userdel -r username :delete all mentions of user in system configuration files and remove user's home directory
3. sudo passwd root :to set up root password
4. sudo adduser username group_name :add a user to a group
5. sudo usermod -a -G sudo core :give sudo privileges to the user core

X. System related commands

1. uname -a :display all basic info about the current system
2. lspci | grep VGA :determine video card info
3. sudo lshw -C :show more detailed info about video card

XI. Useful Utilities

1. whatis command_name :display 1 line summary of the specific command
2. id username :display all the groups that the user belongs to.

References

[1] Roderick W. Smith, Linux essentials, Sybex, 2012

Friday, February 5, 2016

Unix/Linux Bash Scripting Day 01

Braces expansion

$echo {1..10..2}  - produce 1 3 5 7 9
$echo {A..Z} - produce A B C ... X Y Z
$touch file{1..10} - produce file1, file2, file3,..,file10

Pipes and redirections

$ls  -l > /dev/null - redirect to nowhere, cannot be seen

Grep tool -  search contents of the file(s)

Awk tool

Sed tool

Network commands

$ping -c 1 www.theage.com.au - only display 1 line
$ping -c 1 www.theage.com.au | grep 'bytes from'
$ping -c 1 www.theage.com.au | grep 'bytes from' | cut -d = -f 4 - produce the turn around time, "-d =" indicates = is the delimiter, -f 4 indicate field number 4.

Bash shell scripts

 #!/bin/bash
# put comments here
ls -la

$chmod u+x myfirstcript.sh - will run myfirstshell without the bash command
$./myfirstscript.sh

Echo command

echo statement
echo 'statement'
echo "statement"

#!/bin/bash
#different uses of echo command

greetings="hello"
echo $greetings, world (planet)! # will produce errors due to no escape characters used
echo $greetings, world \(planet\)! # will produce the correct sentence.
echo '$greetings, world (planet)!' # will produce the whole string without using the variable $greetings
echo "$greetings, world (planet)!" # will use the variable $greetings





Examples of Aims, Goals, Objectives, Tasks

1. Example 1

Goals

The goal of Conceptual Data Modeling is to develop an entity-relationship model that represents
the information requirements of the business.

Objectives

1. Identify and model entities.
2. Analyze and model the relationships between entities.
3. Analyze and model attributes
4. Identify unique identifiers for each entity.
5. Develop a basic entity-relationship model from a mini-business case that contains information requirements and user interviews.

2. Example 2

Thursday, February 4, 2016

Mind maps Day 04: "Lesson Plan","Why do we need 43 universities in Australia?"

Fig. 1: An example of mind maps "Lesson Plan" produced by Mind Maple.

Fig. 2: A mind map produced from an article on the Age newspaper at [1].


References
1. Tony Featherstone, "Does having 43 universities add up?", the Age newspaper online, http://goo.gl/zmTrd1

UNIX/Linux/Ubuntu system administration DAY 07

System commands

sudo poweroff - shutdown machine
sudo reboot - restart machine

lsb_release -a - get Ubuntu version
uname -r - get kernel version
uname -a - get all kernel information

start service - start job service
stop service
status service

sudo /etc/init.d/service start
sudo /etc/init.d/service stop
sudo /etc/init.d/service status
sudo /etc/init.d/servcie restart

sudo rm /var/crash/* -remove any old crashes

Package management commands

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade - upgrade Ubuntu version or installs updates (new ones)
sudo apt-get install package_name -install package
sudo apt-get purge package_name - uninstall package
sudo apt-get autoremove -remove obsolete packages
sudo apt-get remove firefox - remove package firefox
sudo apt-get remove -purge firefox - remove package firefox and its configuration files
sudo apt-get -f install -fix broken packages

sudo apt-cache search games | grep kde - find all games-related packages for KDE

sudo apt-get clean - delete all the cached DEB files
sudo apt-get autoclean - delete cached DEB files that are beyond a certain date

dpkg -i pkg.deb -install file pkg.deb
cat /etc/apt/sources.list - APT repository list

Environment status

printenv
quota - display disk quota
history
finger - output user information
chfn - change user real name and information
!n - run the recent command n_th

Login Screen Options Commands and fix Display Resolution

sudo dpkg-reconfigure gdm
sudo dpkg-reconfigure lightdm (Ubuntu default option)

sudo mv /usr/share/gnome-shell/theme/ /usr/share/gnome-shell/theme.old
sudo apt-get install --reinstall gnome-shell-common

sudo /etc/init.d/gdm restart -restart X and return to login (GNOME)
cat /etc/X11/xorg.conf - display configuration

sudo dexconf -reset xorg.conf configuration
Ctrl+Alt+Bksp -restart X display if frozen
Ctrl+Alt+FN -switch to tty N
Ctr+Alt+F7 -switch back to X display

sudo apt-get install virtualbox-guest-dkms - fix display resolution

Networking commands


Steps to install Linux software

./configure
make
make install




Mounting USB drives in Windows Subsystem for Linux

Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...