Find

Finding Files with Names
=========================


Find Files Using Name in Current Directory

Find all the files whose name is svk.txt in a current working directory.

# find . -name svk.txt


Find Files Under Home Directory
Find all the files under /home directory with name svk.txt.

# find /home -name svk.txt

Find Files Using Name and Ignoring Case

Find all the files whose name is svk.txt and contains both capital and small letters in /home directory.

# find /home -iname svk.txt

Find Directories Using Name
Find all directories whose name is svk in / directory.

# find / -type d -name svk


Find PHP Files Using Name
Find all php files whose name is svk.php in a current working directory.

# find . -type f -name svk.php


Find all PHP Files in Directory

# find . -type f -name "*.php"


Find Files Based on their Permissions
===================================


Find all the files whose permissions are 777.

# find . -type f -perm 0777 -print


Find all the files without permission 777.


# find / -type f ! -perm 777

Find all the SGID bit files whose permissions set to 644.

# find / -perm 2644

Find all the Sticky Bit set files whose permission are 551.

# find / -perm 1551

Find SUID Files

# find / -perm /u=s

Find all SGID set files.

# find / -perm /g+s

Find all Read Only files.

# find / -perm /u=r

Find all Executable files.

# find / -perm /a=x

Find all 777 permission files and use chmod command to set permissions to 644.

# find / -type f -perm 0777 -print -exec chmod 644 {} \;

Find all 777 permission directories and use chmod command to set permissions to 755.

# find / -type d -perm 777 -print -exec chmod 755 {} \;


To find a single file called svk.txt and remove it.

# find . -type f -name "svk.txt" -exec rm -f {} \;

Find and remove Multiple File
To find and remove multiple files such as .mp3 or .txt, then use.

# find . -type f -name "*.txt" -exec rm -f {} \;
OR
# find . -type f -name "*.mp3" -exec rm -f {} \;

To file all empty files under certain path.

# find /tmp -type f -empty

To file all empty directories under certain path.

# find /tmp -type d -empty

To find all hidden files, use below command.


# find /tmp -type f -name ".*"

Search Files Based On Owners and Groups
===================================


Find Single File Based on User
To find all or single file called svk.txt under / root directory of owner root.

# find / -user root -name svk.txt

Find all Files Based on User
To find all files that belongs to user svk under /home directory.

# find /home -user svk


Find all Files Based on Group

To find all files that belongs to group Developer under /home directory.

# find /home -group developer

Find Particular Files of User

To find all .txt files of user svk under /home directory.

# find /home -user svk -iname "*.txt"

Find Files and Directories Based on Date and Time
=========================================


Find Last 50 Days Modified Files
To find all the files which are modified 50 days back.

# find / -mtime 50


Find Last 50 Days Accessed Files

To find all the files which are accessed 50 days back.

# find / -atime 50


Find Last 50-100 Days Modified Files

To find all the files which are modified more than 50 days back and less than 100 days.

# find / -mtime +50 –mtime -100


Find Changed Files in Last 1 Hour
To find all the files which are changed in last 1 hour.

# find / -cmin -60

Find Modified Files in Last 1 Hour

To find all the files which are modified in last 1 hour.

# find / -mmin -60


Find Accessed Files in Last 1 Hour

To find all the files which are accessed in last 1 hour.

# find / -amin -60

Find Files and Directories Based on Size
===================================


Find 50MB Files
To find all 50MB files, use.

# find / -size 50M

Find Size between 50MB – 100MB

To find all the files which are greater than 50MB and less than 100MB.

# find / -size +50M -size -100M

Find and Delete 100MB Files
To find all 100MB files and delete them using one single command.

# find / -size +100M -exec rm -rf {} \;

Find Specific Files and Delete
Find all .mp3 files with more than 10MB and delete them using one single command.

# find / -type f -name *.mp3 -size +10M -exec rm {} \;

Things-ToDo-After-ubuntu-installtion

1.Install Gnome Classic desktop
--------------------------------------------------------------


# apt-get install gnome-session-flashback

Ubuntu Tweak Tool

Ubuntu Tweak Tool allows you to customize things like fonts, themes etc, that are otherwise difficult or impossible with the "unity-control-center" tool of Unity desktop.

# add-apt-repository ppa:tualatrix/ppa
# apt-get update
# apt-get install ubuntu-tweak


$ ubuntu-tweak

Take window title bar buttons to the right

$ gsettings set org.gnome.desktop.wm.preferences button-layout 'menu:minimize,maximize,close'

Disable overlay scrollbars

On Ubuntu with unity installed, the scrollbars are the overlay scrollbars. In order to revert to the old style plain scrollbar, run the following command

$ gsettings set com.canonical.desktop.interface scrollbar-mode normal

Or run dconf-editor and go to com > canonical > desktop > interface and set the scrollbar-mode value to normal.

Fix the missing menu and button icons


By default, the gnome flashback session does not show icons in dropdown menus and buttons.
To enable these run the following commands
$ gsettings set org.gnome.desktop.interface menus-have-icons true
$ gsettings set org.gnome.desktop.interface buttons-have-icons true


Disable compositing in metacity to speed up

If your system is low on hardware and you need to speed up things, then use the metacity desktop and disable compositing.
Doing so would remove the desktop effects like shadows etc.
Open dconf-editor and go to the following path.
org > gnome > metacity

Find the setting called compositing-manager and uncheck it.
It would take effect instantly and windows would lose their shadows. But it would also speed up the desktop user interface.
Find another setting called 'edge-tiling' and uncheck it to speed up window dragging.


2.Adobe-Flash Player
--------------------------------------------------------------


Open /etc/apt/sources.list file . Find and uncomment the below lines .

# vi /etc/apt/sources.list
...
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

#
# apt-get update
# apt-get install adobe-flashplugin


Now just open http://www.adobe.com/software/flash/about/ in your browser and you can see the flash player version details

3.Install Java browser plugin
--------------------------------------------------------------


The java browser plugin enables the browser to run java applets.
Install the icedtea plugin to make java work inside firefox browser.

# apt-get install icedtea-plugin
OR
# apt-get install icedtea-7-plugin openjdk-7-jre

After installation, close firefox and reopen it and go to http://javatester.org/version.html to verify that the java plugin is working.

4.Install Multimedia Codecs
--------------------------------------------------------------


# apt-get install ubuntu-restricted-extras libavcodec-extra
# apt-get install vlc


5.Hardinfo - System information tool
--------------------------------------------------------------


Hardinfo is a gui tool that reports details about various hardware components in an easy to read format.

# apt-get install hardinfo

6.Install Archive utilities
--------------------------------------------------------------


Certain proprietory archive utilities are not installed on Ubuntu by default.
Adding them would enable your system to read additional archive formats and extract files out of them without problems.

# apt-get install unace rar unrar p7zip-rar p7zip sharutils uudeview mpack arj cabextract lzip lunzip plzip


7. Install Wine
--------------------------------------------------------------


Wine is a Windows emulator and allows you to run Windows applications on your Ubuntu system.

# apt-get install wine winetricks

8.Install a Torrent Client
--------------------------------------------------------------


Ubuntu comes with “Transmission” which is a great torrent client, but it lacks a good interface and is not that practical.
Instead you can install qbittorent which has a more modern look and is much easier to use.

# apt-get install qbittorrent

9.Install Compiz
--------------------------------------------------------------


Compiz provides different awesome desktop effects for your desktop.
Visual effects on the desktop like shadows and animations are managed by Compiz.
The compiz settings can be modified using the Compiz Settings Manager.

# apt-get install compizconfig-settings-manager compiz-plugins

To run it, search for Compiz in the dash or run the following command

$ ccsm

10.Install package management tools
--------------------------------------------------------------


Synaptic is a package manager that allows you to install/update/uninstall different packages as well as fix broken dependencies.
And all this, with an easy to use graphical interface.
The Gdebi tool is an excellent tool to install third party deb files along with necessary dependency packages.

# apt-get install synaptic gdebi

11.Get some Wallpapers and Themes
--------------------------------------------------------------


By default Ubuntu ships with few wallpapers. There are plenty more wallpapers already there in the repositories and can be installed easily.

Install the following packages from the commandline

# apt-get install ubuntu-wallpapers-* ubuntukylin-wallpapers-* ubuntustudio-wallpapers
# apt-get install gnome-themes-*  shimmer-themes


12.Install Gksudo
--------------------------------------------------------------


The gksudo command is used to launch gui programs with root privileges from the command line

# apt-get install gksu


Now run gui application using gksudo to run them as root.

$ gksudo nautilus

13.Disable IPv6
--------------------------------------------------------------


Add the following lines at the end of that file

# vi /etc/sysctl.conf
...
# IPv6 disabled
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

#

# sysctl -p




To Get FileSystem Used more than 85%



# df -h | awk 'NR>1 {print $0}' | sed -e 's/%//g' | awk '$5>=85 { print "\n===================================""\nFS " $6 " of size " $2 " ""is used  " $5 "%""\n===================================" } '

ScrPtS-Mics


# find /test -type f -exec sed -i 's/ugly/beautiful/g' {} \; --- Replace the word ugly to beautiful from all the files in the Directory "/test" and save the same.

# find /etc -type f -exec grep -ilw "/run" {} \; --- Find all files which contains the word "/run" in /etc directory

# scp -v $(find /var/cache/yum -name *.rpm) root@200.0.0.10:/Softwares/Packages --- Copy rpm's to remote system

# echo 'egrep -v "^#|^$" $1' > uv;chmod +x uv;ln -s /root/uv /bin/uv --- New uv command to remove # and blank lines

# echo -e 'for i in $(ls /var/log/{nova,neutron}/*)\ndo\n>$i\ndone' >cleanlog.sh --- Script using echo command

AWK


# awk '/foo/ { print $0 }' test.txt --- To display all lines in which contain the word "foo"

# awk -F: '$3==$4' /etc/passwd    --- Print every line which has the same USER ID and GROUP ID

# awk -F: '{ print $1 }' /etc/passwd | sort --- Print a sorted list of the login names of all users

# awk -F: '$7 ~/bash/' /etc/passwd  --- To display all lines which contain the word "bash" in the 7th column

# awk -F: '$7~"bash|sh" {print $0}' /etc/passwd --- To display all lines which contain the word "bash" or "sh" in the 7th column as the field seperator is ":"

# awk -F ':' '$3>=100 && $NF ~ /\/bin\/sh/' /etc/passwd ---  Print user details who has USER ID greater than or equal to 100 and who has to use /bin/sh

# awk -F ':' '$5 == "" ' --- Print user details who doesn’t have the comments in /etc/passwd file

# echo -n "Total users using BASH Shell = "; awk -F ':' '$NF ~ /bash/ { n++ }; END { print n}' /etc/passwd  --- To print total number of users using bash shell

# awk '/^admin/{print}' /etc/hosts 
  ---  It matches all the lines that start with the pattern 'admin'

# awk '/[0-9]/{print}' /etc/hosts  
  ---    All the line from the file /etc/hosts contain at least a single number [0-9]

# awk '/l.c/{print}' /etc/hosts    ---    The (.) will match strings containing loc, localhost, localnet .(* l some_single_character c *).

# awk '/[al1]/{print}' /etc/hosts    ---    Awk will match all strings containing character a or l or 1 in a line in the file /etc/hosts

# awk '/[Kk]T/{print}' /etc/hosts    ---    Matches strings starting with either K or k followed by T:

# awk '/l*c/{print}' /etc/localhost    ---    It will match strings containing localhost, localnet



SED


# sed -i '2 d' file.txt    --- Delete the 2nd line from file and save

# sed -i 's/Word to Repace/New Word/g' file.txt  ---> Replace a word or Line in the file and save

# sed '1,4d' test.txt --- To delete from line 1,4

# sed '/^$/d' test.txt --- To delete blank lines

# sed -i 's/Today/TODAY/g' test.txt  --- To replace the word "Today" to "TODAY" and save the file in all lines

# cat /etc/passwd | sed -n '1,3p'    ---    To Print lines 1 to 3

# cat /etc/passwd | sed 's:/root:/user1:g' 
   ---    Alternative String Separator

# cat testing | sed '/^daemon/d'    ---    matches all the lines starting with daemon and then deleting them

# cat testing | sed '/sh$/d'    ---     Delete all the lines ending with sh
# sed -i 's/Today/TODAY/g' test.txt  --- To replace the word "Today" to "TODAY" and save the file in all lines

To Replace Line starting with word "    filter" to "filter = [ "a/sdx/", "r/.*/"
 
# echo -en "\e[1;96m Enter LVM-HDD Name \e[0m ( Like sdb or xvdb ) : " ; read lvm_hdd

# sed -i "/^    filter/s/filter.*/filter = [ \"a\/$lvm_hdd\/\", \"r\/.*\/\" ]/g" /etc/lvm/lvm.conf


# grep filter /tmp/lvm.confs

GREP


# grep -v "Word"  --- To remove the line containing the specific word form output

# grep -w "Word   --- Filter lines contains specific word 

# grep -nrwi address /etc --- Find word "address" in files of /etc directory and subdirectores recursively with line number

# grep  -E "abc|xyz"  file1 --- To display all lines in the file1 file that match either the abc or xyz string

# grep -B 1 "1 received" test.txt --- Print Matched line and line above the mathed line

Win Tips used in CMD


attrib +h +s +r "Folder Path" /S /D ===== For Hide Everything inside the path

attrib -h -s -r "Folder Path" /S /D  ===== For UnHide Everything inside the path
dir /p                                            ===== Page wise Listing
dir /ah                                          ===== Only Hidden File Listing

dir /ahD                                        ===== Only Hidden Folder Listing

type                                              ===== To read a text file

getmac                                         ===== Get the MAC address

To find a file in System(Eg; To Find Location of Boot.ini file)
------------------------------------------------------------------------------ 
dir c:\ /s /a /b | find "boot.ini"     

To copy files which has long names
------------------------------------------------
XCOPY "Source file/Dir" "Destination Path" /s /n

Windows Control Panel Applets

access.cpl ---- Accessibility Options
appwiz.cpl ---- Add or Remove Programs
desk.cpl ---- Display Properties
hdwwiz.cpl ---- Add Hardware Wizard
inetcpl.cpl ---- Internet Properties
intl.cpl ---- Regional and Language Options
joy.cpl ---- Game Controllers
main.cpl ---- Mouse Properties
mmsys.cpl ---- Sounds and Audio Devices Properties
ncpa.cpl ---- Network Connections
nusrmgr.cpl ---- User Accounts
nwc.cpl ---- Gateway Services for NetWare Properties
odbccp.cpl ---- ODBC Data Source Administrator
powercfg.cpl ---- Power Options Properties
s32lucp1.cpl ---- Norton Live Update Properties (if using Norton Antivirus)
sysdm.cpl ---- System Properties
telephon.cpl ---- Phone and Modem Options
timedate.cpl ---- Date and Time Properties
sapi.cpl ---- Speech Properties
irprops.cpl ---- Infrared Properties
mlcfg32.cpl ---- Mail Setup (only with Office)

MMC Shortcuts – Management Tools


adsiedit.msc ------ ADSI Edit
sidewalk.msc ------ SID Security Manager
certmgr.msc ------ Certificates
ciadv.msc ------ Indexing Service
compmgmt.msc ------ Computer Management
devmgmt.msc ------ Device Manager
dfrg.msc ------ Disk Defragmenter
diskmgmt.msc ------ Disk Management
eventvwr.msc ------ Event Viewer
fsmgmt.msc ------ Shared Folders
gpedit.msc ------ Group Policy
lusrmgr.msc ------ Local Users and Groups
ntmsmgr.msc ------ Removable Storage
ntmsoprq.msc ------ Removable Storage Operator Requests
perfmon.msc ------ Performance
rsop.msc ------ Resultant Set of Policy
secpol.msc ------ Local Security Settings
services.msc ------ Services
wmimgmt.msc ------ Windows Management Infrastructure (WMI)
comexp.msc ------ Component Services

Restore Desktop Icon


If you Windows Desktop icon is disappeared , there is a quick way to restore it.

Follow the steps bellow:
• Open Notepad

• Paste the text bellow

[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop

• Save the file as Desktop.scf and drag it to your Quick Launch bar

Note: If you can’t place it you Quick Launch bar may be locked.

To unlock it :Right click on it , and remove selection from “Lock The Task Bar”

Bootable Windows 7 USB



While out there are many utilities or tools for one to create a bootable USB drive for Windows 7 installation, the DiskPart program comes with Windows XP or above can also be used to get this job done without extra cost.

How to create bootable USB drive of Windows 7 installer via diskpart command.

























You should able to follow these steps, to create a bootable Windows 7 USB flash drive, in Windows XP or higher. In brief, the key point is using diskpart to set a partition to active (bootable) and then copy the Windows 7 DVD content into this active partition.

1) Connect a USB flash drive (min. 4GB for Windows 7 Ultimate 64-bit).

2) Open Command Prompt window and execute diskpart. In Windows Vista / Windows 7, you need to run Command Prompt with elevated privilege.

3) At DiskPart prompt, type list disk to display a list of mounted disk drive detected by Windows. In the list, you should be able to recognize the USB flash drive connected to Windows, by looking at the Size column. (In my screenshot, this is disk 2).

4) So, execute select disk 2 and then run list partition to display the partition table of the selected disk 2 (i.e. the connected USB flash drive).

Having said that, it’s possible to create multiple partitions on a big USB flash drive (16/32GB or bigger), and uses one of the partition that is fit for the Windows 7 installation files. As mentioned earlier, 4GB is recommending for Windows 7 Ultimate 64-bit.

5) Execute select partition 1, suppose I would like to choose this partition to work on. Indeed, that is the only partition on the USB flash drive.

6) Now, execute active to set the selected partition as active partition (i.e. bootable partition). By then, the list partition report will display an asterisk mark in front of the “active” partition record.

7) Exit from DiskPart program and proceed to use robocopy to duplicate Windows 7 DVD contents to the “active” partition of USB flash drive. For example:

robocopy D:\ E:\ /MIR /V /FP /LOG:C:\Win7.log /TEE

Where D: is the DVD drive containing the Windows 7 DVD; E: is the active partition of USB flash drive; /MIR is to mirror whatever inside the source to the destination; the rest of option switches used are for logging purpose.

Once the robocopy completes successfully, there you will have a bootable USB flash drive for Windows 7 installation :-)

Docker-Commands

To Download all images from fedora repository

# docker pull fedora  
 

To search all of the publicly available CentOS  images on Docker Hub

# docker search centos

To search all of the publicly available CentOS-6.5  images 

# docker search centos-6.5

To Download centos-6.5 from the public repo "svk/centos" 
                                                      
# docker pull svk/centos:centos-6.5

To Rund downloaded centos-6.5
                                            
# docker run -i -t --name CentOS-6.5 svk/centos-6.5-x86_64 /bin/bash

Run a ubuntu 12.04 container

# docker run -t -i --name UB-12-Dock ubuntu:12.04 /bin/bash
 
Run a CentOS 6.6 container

# docker run -i -t --name CentOS-6 centos:6 /bin/bash
                           
To list localy available images

# docker images
                                                                       
List all containers

# docker ps -a 
                                                                      
List Only Running containers

# docker ps 
                                                                           
To Stop a Running container

# docker stop containerID/Name
                                                   
To Remove a stopped container

# docker rm containerID/Name
                                                   
Remove all Docker Containers

# docker rm $(docker ps -aq)
                                                        
Finding out more about a container

# docker inspect containerID/Name
                                            
To access a Running Container

# docker attach container-id/Name

Docker-TiPs

1.Install Docker
==================================

For Ubuntu

# apt-get install docker
# whereis docker
(If docker command not any "bin" directories then make soft link
 # ln -sf /usr/bin/docker.io /usr/local/bin/docker  )
Provide docker access to a User
# usermod -aG docker ubadmin
(add group docker if not exist)

For CentOS 

# yum install docker

2.Push Images to a Private Repository
==================================


# docker login
# docker pull cloudofsvk/ubuntu:14.04
# docker run -t -i --name UB-14-Dock ubuntu:14.04 /bin/bash


(Install required packages on container and Run "exit" command to stop the container; e.g; Here Installed Samba,OpenSSH-Server,nmap on Container)
SynTax ---- # docker commit -m="Commit Description" --author="Author Name" :

# docker commit -m="UB-14.04 custom image-ssh-nmap-samba" --author="---SVK---" 78d2254a0130 cloudofsvk/mydocker:smb-ssh-nmap-server

# docker push cloudofsvk/mydocker


3.Pull Images form a Private Repository
==================================

# docker login
# docker pull cloudofsvk/mydocker
# docker images
# docker run -ti --name


4.Convert a Container to Docker Imagefile
==================================


Create a Container install required packages and exit ,After convert the container to Image using following syntax
SynTAx:------  docker commit -a <"Author Name"> -m <"Description/AnyNotes">

# docker commit -a "SVK-Test" -m "SSH with NginX UB12.04" ddf828798ebe test/os:nginx_ssh





5.Rename/Tag a Docker Image
==================================

# docker images
REPOSITORY   TAG      IMAGE ID            CREATED             VIRTUAL SIZE
ub12_04            NginX   0845a8d1350e     18 minutes ago      125.8 MB

#

# docker tag 0845a8d1350e svk/myimages:NGINX_UB_12.04
# docker images
# docker rmi ub12_04:NginX
# docker images

REPOSITORY   TAG      IMAGE ID            CREATED    VIRTUAL SIZE
svk/myimages   NGINX_UB_12.04  0845a8d1350e  20 minutes ago      125.8 MB

#

6.Flatten Your Image (Remove Layesrs)
====================================





Run Image which has a lot of layer

$ docker run -d /bin/bash   
 7423d238b754e6a2c5294xxxx.....
$
(The output shows the ID of the container)
Since the image doesn't really do anything it exits immediately and we're left with a stopped container that is union of all our image layers(I used the -d flag here only so that the ID of container would be displayed).

Export that container and pipe the contents into the docker import command , can turn the container back into an image:

$ docker ps -a
$ docker export 7423d238b | docker import - sample:new_img

3995a1f00b91efb01xxxx.....
$

$ docker history sample:new_img
IMAGE               CREATED             CREATED BY          SIZE
3995a1f00b91        12 seconds ago                          85.18 MB

$

7.Docker Port Forwarding
====================================


Forward default ssh port 22to 2002 and nginx port 80 to 8000

$ docker run -d --name nginx-1 -p 8000:80 -p 2002:22

8.Connect to a Container Running in Background
====================================


Use 'docker exec' to connect to a detached container

$ docker exec -ti /bin/bash

Connect to a WiFi During Startup


Edit /etc/rc.local and add below line above exit 0
# vi /etc/rc.local
...
nmcli con up id  SSID
exit 0

#

OR

Remove Gnome Network Manager by typing in

#apt-get remove --purge network-manager 
 
Edit /etc/network/interfaces file to look like the following
(SSID and WEP key set accordingly):

# vi  /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet static
address 100.0.0.15
netmask 255.255.255.0
gateway 100.0.0.1
wireless-essid MYSSID
wireless-key 12345678912345678912345678

#

Ubuntu-Theming

1.Install Ubuntu-Tweak Tool
==========================

# add-apt-repository ppa:tualatrix/ppa
# apt-get update
# apt-get install ubuntu-tweak

2.Install Mac-OS-X Theme
=================== 


To Install Mac OS X Lion Theme and Icons on Ubuntu
# add-apt-repository ppa:noobslab/themes
# apt-get update
# apt-get install mac-os-x-icons
# apt-get install mac-os-x-theme



3.CCSM-Compiz-Settings-Manager
============================

Install CCSM

# apt-get install compiz compizconfig-settings-manager compiz-plugins

If CompizSettingsManager Not opening,then
Try to remove "compizconfig-backend-kconfig" and the open agian

# apt-get remove compizconfig-backend-kconfig

4.Workspace Switcher Problem in Ubuntu 14.04

==================================

Open Compiz-Settings-Manager and go to General-GeneralOptions-Desktopsize

$ ccsm

Horizondal Virtualsize = 2
Vertivcal  Virtualsize = 2


5.Install the Windows 7 Theme on Ubuntu 12.04
========================================

# add-apt-repository ppa:upubuntu-com/gtk3
# apt-get update
# apt-get install win2-7

6.Change the Ambience theme Bg colour
==================================

For Green--->gsettings set org.gnome.desktop.interface gtk-color-scheme "selected_bg_color:#009965"
 Ambience(Default) Theme to DarkGreen

# cd /usr/share/themes/Ambiance

Find selected_bg_color code
# grep  selected_bg_color:# */*  

Find selected_bg_color code occurance
# grep 6CA028 /usr/share/themes/Ambiance/*/*

Replace color in theme files

# sed -i 's/f07746/009965/g' gtk-3.0/settings.ini
# sed -i 's/f07746/009965/g' gtk-3.0/gtk-main.css
# sed -i 's/f07746/009965/g' gtk-2.0/gtkrc



7.Install MDM to replace  LightDM
==============================
# add-apt-repository ppa:nilarimogard/webupd8
# apt-get update
# apt-get install mdm mint-mdm-themes

# dpkg-reconfigure mdm
# service lightdm stop
# service  mdm  start

XenServer



1. Enable Promiscious Mode
========================= 

Enable Promiscious Mode on Physical Device
-------------------------------------------------------------------------
# xe pif-list
uuid ( RO)                  : 175c7c48-c480-bc2f-660a-8aee62b5310b
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 8754f21e-aff3-aa6b-d2ef-f0a053025100
uuid ( RO)                  : 2023c9f9-1867-54fb-23c0-6901970c79c9
device ( RO): eth1
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 5d2a36b0-7315-66c2-7618-685d11ea3a10

#

# xe pif-list device=eth0
uuid ( RO)                  : 175c7c48-c480-bc2f-660a-8aee62b5310b
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 8754f21e-aff3-aa6b-d2ef-f0a053025100

#

# xe pif-param-set uuid=175c7c48-c480-bc2f-660a-8aee62b5310b  other-config:promiscuous="true"


# xe pif-param-list uuid=175c7c48-c480-bc2f-660a-8aee62b5310b
...
other-config (MRW): promiscuous: true
This indicates that promiscuous mode is active on the PIF.

#

Enable Promiscious Mode on Virtual/Guest Device
------------------------------------------------------------------------------------

# xe vif-list vm-name-label=Network-Cent7
# xe vif-param-list uuid=
# xe vif-param-set uuid=824f3f41-5866-3930-6936-95c859477c25 other-config:promiscuous="true"
In the output of this command you can see the following line:
# xe vif-param-list uuid=824f3f41-5866-3930-6936-95c859477c25
...
other-config (MRW): promiscuous: true
This indicates that promiscuous mode is active on the VIF.

#


2.Change-Dom0-Memory
========================


Log on to dom0 as root by using the console in XenCenter or by SSH access.

Change the existing dom0_mem parameter to read dom0_mem=2940M in the append line of the xe and xe-serial sections.
    Following is a sample for reference:
    Change the following:
    label xe # XenServer kernel mboot.c32 append /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console=com1 vga=mode-0x0311 --- /boot/vmlinuz-2.6-xen root=LABEL=root-ecpmuteu ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-2.6-xen.img
    to:
    label xe # XenServer kernel mboot.c32 append /boot/xen.gz dom0_mem=2940M lowmem_emergency_pool=1M crashkernel=64M@32M console=com1 vga=mode-0x0311 --- /boot/vmlinuz-2.6-xen root=LABEL=root-ecpmuteu ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-2.6-xen.img
    Note: Adjust dom0 Memory Settings:
    The dom0_mem=2940M change allocates more memory to dom0, which implies that it can better handle large numbers of virtual machines. After changing this setting and restarting, provide specific instructions to ensure that dom0 consumes all the memory allocated to it.

# vi /boot/extlinux.conf
serial 0 115200
default xe
prompt 1
timeout 50

label xe
  # XenServer
  kernel mboot.c32
  append /boot/xen.gz dom0_mem=2048M,max:2940M watchdog dom0_max_vcpus=4 crashkernel=128M@32M cpuid_mask_xsave_eax=0 console=vga vga=mode-0x0311 --- /boot/vmlinuz-3.10-xen root=LABEL=root-yrmitkif ro hpet=disable xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-3.10-xen.img

label xe-serial
  # XenServer (Serial)
  kernel mboot.c32
...

#

# init 6


Check memory after reboot

3.Unable to shutdown VM
======================


Unable to shutdown - dracut loop rm: cannot remove /lib/drauct/hooks/shutdown/30-dm-shutdown.sh: Read-only

Sol:

# vi /etc/dracut.conf.d/shut.conf
omit_dracutmodules+="shutdown"
#

# reboot


4.Xen-In-Xen( Enable VTx for VM inside xenserver)
=============================================


Create New VMs inside XenServer Using "Other Install Media" option which will enable HVM(HardwareVirtualisation)
Then After installing VM shutdown the same and set "exp-nested-hvm=true" for the VM i.e,

Login to XenServer


# xe vm-list
# xe vm-param-list uuid=xxxxxxxxxxxxxxx|grep exp-nested
# xe vm-param-set uuid=xxxxxxxxxxxxxxx platform:exp-nested-hvm=true

Login to VM and run

# egrep -i "vmx|svm" /proc/cpuinfo

Note--Check the Detected N/W interface HWaddr and rectify if N/W problem occures (In Some case The interface eth0 will not appers as defalt use eth1 in that case..)

VirtualBox

1.DePs For Ubuntu/CentOS To install VirtualBox
=======================================


# apt-get install linux-headers-$(uname -r) build-essential  dkms
# yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel \
kernel-headers kernel-devel dkms


2.Install Extension-Pack
====================


add the user that will run VirtualBox (sysadmin in this example) to the vboxusers group:

# adduser sysadmin vboxusers

# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.18-78361.vbox-extpack



3.Starting A VM With VBoxHeadless
===============================


Regardless of if you create a new VM or import an old one, you can start it with the command:

# VBoxHeadless --startvm "Ubuntu 12.04 Server"

To list of available VMs
# vboxmanage list vms

To start machine
# vboxmanage startvm vmname --type headless

4.Power off  virtual machine using the command
========================================


# VBoxManage controlvm "Ubuntu 12.04 Server" poweroff



5.Clone HardDisk
================


# VBoxManage clonehd /Vbox/oldxp.vdi  /Vbox/newxp.vdi

6.Change UUID of VDI Dusk
=======================


C:\ >  VBoxManage internalcommands sethduuid "C:\Users\Name\VirtualBox VMs\Example\Example.vdi"  --- Windows

# VBoxManage internalcommands setvdiuuid /path/to/virtualdisk.vdi   --- LInux



7.To start a VM during startup
============================


Add entry to "/etc/rc.local" as follows and restart the system

# vi /etc/rc.local

..
su - (username) -c "VBoxHeadless --startvm (OS-Name) &"su - adminad -c "VBoxHeadless --startvm UB12-x64-L300 &"

#
8.Increase a VirtualBox HDD (VDI) size
=====================================

Increase a hdd size to 40GB

# vboxmanage modifyhd /VM/Win7-Test.vdi --resize 40000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
#

9.Convert VMware VMDK to VirtualBox VDI
=======================================

To convert VMDK to VDI with VboxManage:

 
$ VBoxManage clonehd --format VDI input.vmdk output.vdi
 

VMWare

1.Enable promiscuous mode vmware
================================

If you want all users to be able to set the virtual Ethernet adapter (/dev/vmnet0 in our example) to promiscuous mode, run the following command on the host operating system as root:

# chmod a+rw /dev/vmnet*

 To grant selected other users read and write access to the VMnet device, you can create a new group, add the appropriate users to the group and grant that group read and write access to the appropriate device. You must make these changes on the host operating system as root (su -). For example, you can enter the following commands:

# chgrp (newgroup) /dev/vmnet0
# chmod g+rw /dev/vmnet0


2.Set BIOS POST screen Delay -VMWare
==================================


To make it easier to access the BIOS setup screen,

edit the virtual machine's configuration (.vmx).

Show Bios screen always without press any key
Chhnage Delay Time
For 10 seconds Delay.

bios.forceSetupOnce = "TRUE"  
bios.bootDelay = "xxxx"
bios.bootDelay = "10000"



3.To uninstall VMWare Workstation
==============================


# vmware-installer --uninstall-product vmware-workstation
If you just run
# vmware-installer
by itself, it will print all the options you have available. If you run
# vmware-installer -l
It will print a list of all VMWare products you have installed.

Brightness--Controll-On-Ubuntu


Find the connected minitor name using xrandr (i.e,VGA1)
Then set brightness from 0.1 to 1.0

$ xrandr
$ xrandr --output VGA1 --brightness 0.7


For autostart

$ gnome-session-properties
[Add StartupProgram]
Name            ---    Brightness-Control
Command        ---    xrandr --output VGA1 --brightness 0.7
Comment        ---    Reduce-Screen-Brightness
[Add]


This will create a File named xrandr.desktop in ~/.config/autostart/ Directory

Reboot the system and check
------------
OR

$sudo gedit /etc/rc.local
# Add this before the last line “exit 0″:
echo 4 > /sys/class/backlight/acpi_video0/brightness


# reboot.
---------
OR

# gedit /etc/default/grub

#You will find this line in the new opened window:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
#Change it to:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
Save and close the window and type this in the terminal:

#
#update-grub
# reboot

Configure SSH-Keybased Auth

Loginto Remote Server and Configure SSH-Keybased Auth
------------------------------------------------------------------------------------------------

# ssh-keygen
# cd ~/.ssh/

 
Add/Append generated Public key to "authorized_keys"file

# cat id_rsa.pub >> authorized_keys
# chmod 600 authorized_keys

 
Copy Private key to Local Client System(from where to connet to this server)

# scp id_rsa ubuntu@192.168.1.222:/F1/SSH-KeyS
# vi /etc/ssh/sshd_config

..
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
PasswordAuthentication no

#
# service sshd restart
#exit


From Local Client System login to server using key file

$ mv /F1/SSH-KeyS/id_rsa /F1/SSH-KeyS/owncloud.key
$ sudo chmod 400 /F1/SSH-KeyS/owncloud.key
$ ssh -i /F1/SSH-KeyS/owncloud.key root@192.168.1.95


============

For Quick Access to Server from Client Machine
-------------------------------------------------------------------------------


Open or create ~/.ssh/config file on client.and then paste following line replacing "owncloud" with the id you want to use and location to .key file with correct one.

# vi ~/.ssh/config
#---Host OwnCloud---#
Host owncloud
HostName 192.168.1.95
User root
IdentityFile "F1/SSH-KeyS/owncloud.key"
#---Host UB-Router---#
Host router
HostName 192.168.1.99
User ubadmin
IdentityFile "/F1/SSH-KeyS/router.key"

#

You are ready to go. Just type:
# ssh owncloud

Set-HD-DisplayResolution-on-HD-Monitor

Run the command as Normal user(Not as Root user)

$ xrandr--------->To Show Conneted Display (default,VGA1..etc--Hereit is default)
VGA1 connected primary 1024x768+0+0......
$

$ cvt 1360 768 60

Modeline "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
$
$ xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
$ xrandr --addmode  default 1360x768_60.00


$ vi ~/.xprofile
xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
xrandr --addmode VGA1 1360x768_60.00
xrandr --output VGA1 --mode 1360x768_60.00

$


$ sudo reboot

=================================


$  xrandr
Screen 0: minimum 320 x 200, current 1360 x 768, maximum 32767 x 32767
VGA1 connected primary 1360x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
.........


GRUB2-Password-for-Ubuntu

Grub2-Boot-Menu-Password-Ubuntu-14.04
========================================


UserName===ubadmin

# grub-mkpasswd-pbkdf2
grub.pbkdf2.sha512.10000............2A0AB42E959
#

Edit the "/etc/grub.d/40_custom" file and set superusers name and above generated encrypted password

# vi /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
set superusers="ubadmin"
password_pbkdf2 ubadmin grub.pbkdf2.sha512.10000............2A0AB42E959

#

Change Line ' CLASS="--class gnu-linux --class gnu --class os" ' to ' CLASS="--class gnu-linux --class gnu --class os --unrestricted" ' in file "/etc/grub.d/10_linux"
Other wise grub will ask for password always .

# vi /etc/grub.d/10_linux
...
CLASS="--class gnu-linux --class gnu --class os --unrestricted"
...

#

# update-grub
# reboot

SystemBack-BackUP/Restore-Ubuntu

SystemBack Installation with GUI :
===============================


System Back is alternative for remastersys
Also it is used to create restore-point like windows using systemback-cli


# add-apt-repository ppa:nemh/systemback
# apt-get update
# apt-get install systemback

To Create a LiveISO
--------------------------------

 
Open SystemBack-GUI   
    Slect LiveSystemCreate
    Change the OPtion if Required
    Select Create New
    After Creation Select Convert to ISO to get bootable iso



For Command Line (On-Server)
=============================
=


 Using systemback-cli can only create restore points,not live ISO

# apt-get install systemback-cli
# systemback-cli   ------> with terminal gui


SimpleScreenRecorder


SimpleScreenRecorder: Ubuntu-14.04

==============================

# add-apt-repository ppa:maarten-baert/simplescreenrecorder
# apt-get update
# apt-get install simplescreenrecorder
# apt-get install ubuntu-restricted-extras


Ubuntu 64bit:To record 32bit games,  install simplescreenrecorder-lib:i386:

# apt-get install simplescreenrecorder-lib:i386

User CTRL+R Key Combination to Pause/Resume Recording

SimpleScreenRecorder: CentOS
============================== 

Download the latest nux-dextop-release rpm 
 
# wget  http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm -P /tmp
 
Install nux-dextop-release rpm:
 
# cd /tmp
# rpm -Uvh nux-dextop-release*rpm
# yum install simplescreenrecorder
 

xRDP-Ubuntu

Ubuntu 12.04
======================


# apt-get install ubuntu-desktop --no-install-recommends
# apt-get install xrdp

# /etc/init.d/xrdp status

# /etc/init.d/xrdp restart



Ubuntu-14.04
======================


For ubuntu Unity Desktop gives a lk screen while connecting thrugh RDP,so need to install ubuntu-mate-desktop

# apt-get install xrdp
# apt-add-repository ppa:ubuntu-mate-dev/ppa
# apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
# apt-get update
# apt-get upgrade
# apt-get install ubuntu-mate-core ubuntu-mate-desktop

# echo mate-session > /etc/skel/.xsession
# service xrdp restart

xRDP-CentOS

Install XRDP Remote Desktop to CentOS-7
====================================


# rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm


OR

# vi /etc/yum.repos.d/xrdp.repo
[xrdp]
name=xrdp
baseurl=http://li.nux.ro/download/nux/dextop/el7/x86_64/
enabled=1
gpgcheck=0

#


# yum install xrdp tigervnc-server
# systemctl enable xrdp.service
# systemctl start xrdp.service
# systemctl enable xrdp-sesman.service
# systemctl start xrdp-sesman.service
# netstat -antup | grep xrdp


# firewall-cmd --permanent --zone=public --add-port=3389/tcp
# firewall-cmd --reload


Configure SELinux

# chcon --type=bin_t /usr/sbin/xrdp
# chcon --type=bin_t /usr/sbin/xrdp-sesman



Install XRDP Remote Desktop to CentOS 6.5
======================================

 
RHEL/CentOS 6 64-Bit

# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm


# yum repolist

# yum install xrdp tigervnc-server
# service vncserver start
# service xrdp start
# chkconfig xrdp on
# chkconfig vncserver on

# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3389 -j ACCEPT
# service iptables save
# iptables -L

XDMCP-RDP-CentOS

For CentOS-6.5-Desktop
----------------------------------------------

# yum install xorg-x11-xdm
# vi /etc/X11/xdm/Xaccess

...
*                                       #any host can get a login window
...

#

# vi /etc/X11/xdm/xdm-config

...
!DisplayManager.requestPort:    0

#

GDM login manager configuration:

# vi /etc/gdm/custom.conf
...
[security]
DisallowTCP=false
[xdmcp]
Enable=true
...

#

[Potential Pitfall]: RHEL6 users may find that the remote X-server has a blank screen when trying to start a remote XDMCP desktop.
This may require a change to the default sshd configuration.Edit file: /etc/ssh/sshd_config
be sure the following three lines are uncommented:

# vi /etc/ssh/sshd_config
 ...
    X11Forwarding yes
    X11DisplayOffset 10
    X11UseLocalhost yes
 ...

#

#  service sshd restart



On Client
================


Install Remmina/TSClient , and connect using GUI

# yum install remmina-*
# remmina
     
                     --->New
Profile   
    Name        --->    XDMCP-Server
    Protocol    --->    XDMCP - X Remote Session
Basic   
    Server            --->    192.168.1.200:1
    Resolution    --->    Use Client Res
    Clolor Depth    ---> Default


OR using Command

# Xephyr :1 -query 192.168.1.200 -geometry 1366x768
# Xnest :1 -query 192.168.1.200
# X :1 -listen tcp -query 192.168.1.200


Xnet-GUI-Client
------------------------------

ServerName    --->        :1  (Use PortNumber Only)
Options        --->        192.168.1.209 -listen tcp



XDMCP-RDP-Ubuntu

For Ubuntu-16.04-Desktop-Server
-------------------------------------------------------------

# cat /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
[SeatDefaults]
user-session=ubuntu
xserver-allow-tcp=true
greeter-show-remote-login=true

allow-guest=false
[XDMCPServer]
enabled=true
port=177

#
# reboot
# netstat -aun|grep 177


For Ubuntu-14.04-Desktop-Server
-------------------------------------------------------------

# cat /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
[SeatDefaults]
user-session=ubuntu
xserver-allow-tcp=true
greeter-show-remote-login=true
[XDMCPServer]
enabled=true
port=177

#

# reboot
# netstat -aun|grep 177


For Ubuntu-12.04-Desktop
----------------------------------------------------


# vi /etc/lightdm/lightdm.conf

[SeatDefaults]
user-session=ubuntu
greeter-session=unity-greeter
allow-guest=false
[XDMCPServer]
enabled=true

#

# reboot
# netstat -aun|grep 177


For Xubuntu-14.04-Desktop-Server
--------------------------------------------------------------


# cat /etc/lightdm/lightdm.conf.d/10-xubuntu.conf
[SeatDefaults]
user-session=xubuntu
xserver-allow-tcp=true
greeter-show-remote-login=true
[XDMCPServer]
enabled=true
port=177

#

# reboot
# netstat -aun|grep 177


On Client
================

Install Remmina/TSClient , and connect using GUI

# apt-get install remmina-*
# remmina
 
                     --->New
Profile   
    Name        --->    XDMCP-Server
    Protocol    --->    XDMCP - X Remote Session
Basic   
    Server            --->    192.168.1.200:1
    Resolution    --->    Use Client Res
    Clolor Depth    ---> Default


OR using Command

 # apt install xserver-xephyr

# Xephyr :1 -query 192.168.1.200 -geometry 1366x768
# Xephyr -query 192.168.1.200 :1 -screen 1200x600
# Xephyr -query 192.168.1.200 :1 -fullscreen


# Xnest :1 -query 192.168.1.200
# X :1 -listen tcp -query 192.168.1.200


Xnet-GUI-Client
--------------------------------

ServerName    --->        :1  (Use PortNumber Only)
Options        --->        192.168.1.209 -listen tcp

Ubuntu-14.04 - Set As a Gatway/Router with Single NIC

Physical Device     == eth0
Virtual Device     == eth0:1  

Edit "/etc/network/interfaces" File


# vi /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0 eth0:1
iface eth0 inet dhcp
iface eth0:1 inet static
address 200.0.0.200
netmask 255.255.255.0
###To restore Iptable Rules After reboot ###
pre-up iptables-restore < /etc/iptables.rules


#


# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -A FORWARD -i eth0:1 -j ACCEPT

# iptables-save > /etc/iptables.rules

# vi /etc/sysctl.conf

net.ipv4.ip_forward=1
#
# sysctl -p

# reboot


On Client Machine set gateway as ipaddress of eth0:1 i.e, 200.0.0.200

Disable the user list on CentOS-Desktop.


Disable the user list on the CentOS7 login screen.
----------------------------------------------------------------------------

Create this file , Add this content to that file:

# vi /etc/dconf/db/gdm.d/00-login-screen

[org/gnome/login-screen]
# Do not show the user list
disable-user-list=true

#

Run this command and restart X, I just rebooted

# dconf update
# systemctl restart gdm


Disable the user list on the CentOS6 login screen.
-----------------------------------------------------------------------------


# gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/gdm/simple-greeter/disable_user_list true

Local-Repositories-CentOS

===========================
CentOS-Local-Repository Over LAN
===========================


# yum install httpd
# chkconfig --levels 235 httpd on
# /etc/init.d/httpd start

Building The Repository
-----------------------------------------------

Create a Directory under /var/www/html and copy the downloaded rpm .

# mkdir -p /var/www/html/yum-repo/rpm
# cp /Downloads/*.rpm /var/www/html/yum-repo/rpm/


Install the createrepo package to build the local repository
# yum install createrepo
Build the repo
# createrepo /var/www/html/yum-repo
# ls -l /var/www/html/yum-repo


Client Configuration
---------------------------------------------


# vi /etc/yum.repos.d/svk.repo
[SVK-Local-RePo]
name=SVK-Linux-RePo
failovermethod=priority
baseurl=http://192.168.0.100/yum-repo
enabled=1
gpgcheck=0

#
# yum repolist