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

No comments:

Post a Comment

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...