Create-Special-User-on-Ubuntu

Create a User WithOut Login through GUI
=================================


User "-r" Option with useradd command

# useradd -s /bin/bash -G sudo -m -r svk
# passwd svk
# su - svk

# mkdir /usr/svk
# chown -R svk: /usr/svk


Create some special Command for that user to Run
---------------------------------------------------------------------------------------


$ cat .profile
...
# set PATH so it includes user's private bin directories
PATH="/usr/svk:$HOME/bin:$HOME/.local/bin:$PATH"

$

$ cat /usr/svk/psql-aws
#!/bin/bash
if [ -z $1 ]; then
    psql -U svk -h odoo-pgsql-xxxxxxxxxx.rds.amazonaws.com
else
    psql -U svk -h odoo-pgsql-xxxxxxxxxx.rds.amazonaws.com -c $1
fi

$
$ chmod +x /usr/svk/psql-aws

APT-update failed error on UBuntu 10.04

Edit the /etc/apt/sources.list file with a text editor,
and wherever see the archive.ubuntu.com (the source of releases actively supported), change it to old-releases.ubuntu.com

# vi /etc/apt/sources.list
....
:%s/archive.ubuntu/old-releases.ubuntu/g
#

Ubuntu-16-Tweaks

“Create new document” - right-click option ====================================
Create one if not, ~/Templates folder.

$ touch ~/Templates/Text\ File.txt
$ touch ~/Templates/Text\ File.txt


"Create Document" option is back again and you can create a new text file or a new document.

Set-Sh-File-to-Ask-on-Opening
====================================

$ gsettings set org.gnome.nautilus.preferences executable-text-activation ask

Rename-Network-Device
====================================

Edit your /etc/default/grub changing the line from
GRUB_CMDLINE_LINUX="" to
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

# vi  /etc/default/grub
...
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
...
#
# update-grub
# sudo reboot


Change the Default Text Editor on Ubuntu
==========================================

$ sudo update-alternatives --config editor
There are 3 choices for the alternative editor (providing /usr/bin/editor).
  Selection    Path               Priority   Status
------------------------------------------------------------
  0            /bin/nano           40        auto mode
  1            /bin/ed            -100       manual mode
* 2            /bin/nano           40        manual mode
  3            /usr/bin/vim.tiny   10        manual mode

Press to keep the current choice[*], or type selection number:

$

To change the default editor to vim,  just hit the number 3.

Change the Default TimeZone
==========================================

# dpkg-reconfigure tzdata
# cat /etc/timezone 

LightDM-Tweaks


To Disable Guest-User from LightDm-LoginScreen
=======================================
# vi /etc/lightdm/lightdm.conf.d/50-myconfig.conf
[SeatDefaults]
allow-guest=false

#

To Enable Manual Login Screen on LightDm-LoginScreen

=======================================
# vi /etc/lightdm/lightdm.conf.d/50-myconfig.conf
[SeatDefaults]
allow-guest=false
greeter-hide-users=true
greeter-show-manual-login=true

#

To Enable AutoLogin on LightDm-LoginScreen
=======================================
# vi /etc/lightdm/lightdm.conf.d/50-myconfig.conf
[SeatDefaults]
allow-guest=false
greeter-hide-users=true
greeter-show-manual-login=true
autologin-user=ubadmin

#


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

Simple-Samba-Server-LinuX


Install and Configure Samba


# yum install samba
OR
# apt-get install samba

# useradd -c "Samba_User1" -d /dev/null -s /bin/false smbu1
# useradd -c "Samba_User1" -d /dev/null -s /bin/false smbu2

# smbpasswd -a smbu1
# smbpasswd -a smbu2

# groupadd SambA

# usermod -aG SambA smbu1
# usermod -aG SambA smbu2

# mkdir -p /samba/share
# chown :SambA /samba/share
# chmod 775 /samba/share

(Here Files created by smbu1 cann't delete files of smbu2 on "/samba/share" Directory and vice versa)

# vi /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
security = user
[ShaRe]
path = /samba/share
valid users = smbu1, smbu2
read only = no
guest ok = no
;instructs samba to allow this share to be displayed on the client network browser.
browsable = yes

#

For-Ubuntu

# systemctl restart smbd
# systemctl enable smbd

For-CentOS

# systemctl restart smb
# systemctl enable smb

# testparm

-----------------------------
Remember that your user must have permission to write and edit the folder you want to share.
For Ubuntu--->Also hide the user on the login screen and allow manual Login adjusting lightdm's configuration

# vi /etc/lightdm/lightdm.conf.d/50-myconfig.conf
[SeatDefaults]
allow-guest=false
greeter-hide-users=true
greeter-show-manual-login=true

#
-----------------------------

Allow Samba Through FireWall Rules
================================


# firewall-cmd --list-all
# firewall-cmd --get-services ---> To get the names of pre-defined services ( Name "samba" will be there)

# firewall-cmd --add-service=samba --permanent
# systemctl restart firewalld

# cat /usr/lib/firewalld/services/samba.xml  ---> For Samba Ports Description


To access your network share
================================


# yum install samba-client
OR
# apt-get install smbclient

List all shares:

# smbclient -L /// -U

connect:

# smbclient /// -U

To access your network share use your username () and password through the path

Linux users     ------ "smb:////"
Windows users     ------ "\\\\"


Note that "" value is passed in "[]", in other words, the share name you entered in "/etc/samba/smb.conf".

    Note: The default user group of samba is "WORKGROUP".

OR
# apt install cifs-utils
# mount -t cifs //10.10.10.101/iso/LinuX/Ubuntu /smb-mnt/ -o username=test,noexec

# mount -t cifs //10.10.10.101/Videos -o username=user1 /mnt/samba/videos
# mount -t cifs //10.10.10.101/Videos -o username=user1,password=mypassword /mnt/samba/videos
================================

AdM-TiPs

1.Split larger files Using 7-zip
----------------------------------------------
# 7z   a   -v50m   -mx0    ubuntu.7z     /test/ubuntu.iso

This will create 50MB size files from the ubuntu.iso. The -v50m is the volume size(use k for kilobytes& g for gigabytes) etc; the -mx0 switch tells 7-Zip to use no compression, that is, just to split data into parts.

To extract just do
#  7z   x   ubuntu.7z.001  
OR
# 7z  e  ubuntu.7z.001

2.Binary-Decimal Conversion
--------------------------------------------------
To Get the decimal value of Binary num 10000000
$echo "ibase=2; 10000000"|bc
To Get the Binary value of Decimal Num 254
$echo "obase=2; 254"|bc


3.To Redetect  Network Card
---------------------------------------------
Comment the acive network line in the files and reboot to redetect network card

/etc/udev/rules.d/70-persistent-net.rules

4.To configure wake-on-lan:
-----------------------------------------------
Install wakeonlan or ether-wake package
Install ethtool in remote system
#apt-get install ethtool
edit /etc/rc.local to add this line before the exit 0 line:
ethtool -s eth0 wol g
or execute  # ethtool -s eth0 wol g
Find out the MAC address of Remote Machine's network card (replace ethX with eth0/eth1, ..):
#ifconfig ethX | grep "HWaddr" | awk '{print $5}'
shutdown the Remote machine. Invoke the below mentioned command from ur System:
#wakeonlan RemoteSys_mac_id

5.Hide Other HDD drives from Nautilus Window
--------------------------------------------------------------------------------
Create a file in /etc/udev/rules.d/  as follows to hide the drives “sda1,2 &7”   as root user
# vi   99-hide-disks.rules 
KERNEL=="sda1",ENV{UDISKS_PRESENTATION_HIDE}="1"
KERNEL=="sda2",ENV{UDISKS_PRESENTATION_HIDE}="1"
KERNEL=="sda7",ENV{UDISKS_PRESENTATION_HIDE}="1

6.Disable Password prompt for sudo commands
----------------------------------------------------------------------------
Edit the %sudo line in /etc/sudoers file as follows
#  vi   /etc/sudoers
%sudo     ALL=(ALL:ALL)   NOPASSWD:   ALL

7.VBOX Driver/VBoxGuestAddition  innstallaton on Linux
-----------------------------------------------------------------------------------------------------
#yum install kernel-devel kernel-headers kernel-PAE-devel gcc SDL Qt gcc-c++
#yum install dkms --------> Optional Required for Host
#export KERN_DIR=/usr/src/kernels/2.6.33.3-85.fc13.i686.PAE/ ----> Optional
For Ubuntu
sudo apt-get install build-essential
mount VBOXGuest addition package... and run ./VBoxLinuxAddition.run

8.To add NTFS file system support 
-----------------------------------------------------------------
Install "fuse" and "fuse-ntfs-3g" packages 

9.To display storage controllers and N/W Card in the system
---------------------------------------------------------------------------------------------------
#lshw -class disk -class storage
#lshw -class network

10.Force umount when the device is busy
----------------------------------------------------------------
# fuser -km /mnt/hda2

11.To find the installed package of a Command.
-------------------------------------------------------------
# which  ls   -----  To find the location of command
# rpm    -qf    /bin/ls  
For Ubuntu
# dpkg   -S   /bin/ls

12.How to umount when the device/mounted directory is busy
----------------------------------------------------------------------------------------
# umount /storage 
umount: /storage: device is busy
umount: /storage: device is busy


This error comes when some running services use this device/directory.So Find out the process ID of the services ,which using the device and kill them one by one ,use the fuser command
# fuser -m /storage or # fuser –m /dev/hdd3
/storage: 2110 2115 2116 2230 ---->Output of the above command..The find the running process using PID
# ps auxw grep 2110 (For Checking the name of process)
Finally Kill each process or stop associated services.
# kill -9 2110 2115 2116 2230
Now the device/directory will be able to umount



Reinstall-Grub-on-LivaPC


1.Boot From Live-CD

2.Mount the Installed Disk to /mnt from root user


( Root Disk will be sda1 or mmcblk0p2 ,check the same using fdisk/gparted utility and change accordingly )

# mount /dev/mmcblk0p2 /mnt
# mount /dev/mmcblk0p1 /mnt/boot/efi
# mount --bind /proc /mnt/proc
# mount --bind /sys /mnt/sys
# mount --bind /dev /mnt/dev

3.Chroot to /mnt

# chroot /mnt
    (    Check internet connection "# ping google.com" ,if not check "# ping 8.8.8.8" ,if working run
        # echo "nameserver 8.8.8.8" >> /etc/resolv.conf    
     )

# apt-get update
# apt-get install grub-efi-amd64  
(Remove grub-common,grub2-common if errror , and then install grub-efi-amd64)

# grub-install /dev/mmcblk0
# update-grub2     (OR # update-grub)
# exit

4.Umount and Reboot

# umount /mnt/dev
# umount /mnt/sys
# umount /mnt/proc
# umount /mnt/boot/efi
# umount /mnt
# reboot