UNIX tutorial

6
Utility Use-Cases sudo Run as administrator man Manual / Help file su Switch User service start a service service stop a service service restart a service service start stop restart vsftpd top CPU / Memory / Process details top Kill a rogue process mount mount a cdrom umount un mount a cdrom fdisk list the filesystem details fdisk work on a DISK fsck File System Check Utility - Check partition mkfs Format a partition df Disk Filesystem Usage: (human readable form) du Disk Usage: List size of All files/folders b du Disk Usage: List sizes UPTO 1 level umask display default permission set in /etc/profi exit logout of current user passwd change password rpm install a standalone rpm package rpm upgrade a standalone rpm package rpm remove a standalone rpm package rpm list packages installed on system yum install yum upgrade yum remove yum list packages that need updates yum list packages available from sources yum list packages installed on system up2date install up2date upgrade up2date remove up2date list packages that need updates up2date list package available form sources up2date install with dependency solved vsftpd enable user access on FTP server /etc/vsftpd vsftpd enable upload access on FTP /etc/vsftpd.conf vsftpd restart vsftpd server lsof List of opened files - which process -> whic lsof List of files opened by a process (eg. Dropb

description

Unix Tutorial

Transcript of UNIX tutorial

Page 1: UNIX tutorial

Utility Use-Casessudo Run as administratorman Manual / Help filesu Switch Userservice start a serviceservice stop a serviceservice restart a serviceservice start stop restart vsftpdtop CPU / Memory / Process detailstop Kill a rogue process mount mount a cdromumount un mount a cdromfdisk list the filesystem detailsfdisk work on a DISKfsck File System Check Utility - Check partitionmkfs Format a partitiondf Disk Filesystem Usage: (human readable form)du Disk Usage: List size of All files/folders beneathdu Disk Usage: List sizes UPTO 1 levelumask display default permission set in /etc/profileexit logout of current userpasswd change passwordrpm install a standalone rpm packagerpm upgrade a standalone rpm packagerpm remove a standalone rpm packagerpm list packages installed on systemyum installyum upgradeyum removeyum list packages that need updatesyum list packages available from sourcesyum list packages installed on systemup2date installup2date upgradeup2date removeup2date list packages that need updatesup2date list package available form sourcesup2date install with dependency solvedvsftpd enable user access on FTP server /etc/vsftpd.confvsftpd enable upload access on FTP /etc/vsftpd.confvsftpd restart vsftpd serverlsof List of opened files - which process -> which filelsof List of files opened by a process (eg. Dropbox)

Page 2: UNIX tutorial

tar backup a directory into a tarball(compressed)tar backup a directory (excluding some files)tar restore backup (to another directory preferably)crontab Edit the crontab file - /etc/crontab.confuseradd Create a new user 'arvind'passwd unlock the new user 'arvind'useradd create a user with DIFFERENT HOME Dir.useradd Create user with specific UID and GUIDuseradd Create user with multiple groupsuseradd Create user with account expiry datechage Verify the age of an accountuseradd Create user with password expiry dateuseradd Create user with specific SHELL

Page 3: UNIX tutorial

Commandsudo rpm -i vsftpdman ping

sudo /etc/init.d/apache2 startsudo /etc/init.d/apache2 stopsudo /etc/init.d/apache2 restartsudo service vsftpd restartsudo toprun top, press 'k' and enter the PIDmount -t iso9660 /dev/cdrom /mnt/cdromumount /mnt/cdrom or umount /dev/cdromfdisk -lfdisk /dev/sdafsck /dev/sda2mkfs -V -t vfat /dev/sda2df -hdu -hdu --max-depth=1 -humask -Sexitpasswdsudo rpm -ivh package.rpmsudo rpm -Uvh package.rpmsudo rpm -e packagesudo rpm -qayum install packageyum update packageyum remove packageyum list updatesyum list availableyum list installedup2date -i packageup2date -u package

up2date -lup2date --show-availableup2date --solvedeps=packagelocal_enable=yeswrite_enable=yessudo service vsftpd restartlsoflsof -i -n -P | grep dropbox

Page 4: UNIX tutorial

sudo crontab -euseradd arvindpasswd arvinduseradd -d /data/projects arvinduseradd -u 1000 -g 501 arvinduseradd -G admins,webadmin,developers arvinduseradd -e 2015-04-30 aparnachage -l aparnauseradd -f 45 arvinduseradd -s /sbin/csh techmahindra

tar -cvpzf wwwbackup.tar.gz /var/www

tar -cvpzf rootbackup.tar.gz --exclude=/mnt /

tar -xvpzf wwwbackup.tar.gz -C /var/recovery

Page 5: UNIX tutorial

Comments

use 'q' to exit a man page

CAUTION: partition should be unmounted

beneath pwd

Page 6: UNIX tutorial

p is very imp. Preserving permissions

# mm hh DoM M DoW cmduser arvind in locked stateunlocks and prompts your for new password

value of 0 will inactive the account as soon as password in expired