Friday, 27 December 2013

USEFULL LINUX COMMANDS

Disk Usage and Disk Free Command
------------------------------------------------------

df -h = free hard drive space
df = free hard drive space
du -sh = disk usage
du -h = hard drive usage

Change Permissions
-------------------------------
chmod o=rwx, g=rw, u=r /usr/local/bin = change file permissions
chmod ogu=rwx /usr/local/bin = change file permissions

Others
-------------
cat /var/log/yum.log
cat /var/log/yum.log | grep mysql = mysql install and update dates
cat /proc/meminfo = prints memory info
cat /proc/cpuinfo = prints cpu info
cat /proc/devices = list of devices
cat /proc/stat = disk statictics
cat /proc/filesystems = file system info
cat /proc/interrupts = IRQ channel assignments
cat /proc/iomem = physical memory addresses
cat /etc/x11/xorg.conf = monitor info
cat -s filename.txt = shows consecutive blank lines as one
cat -n filename.txt = shows all lines with numbers
cat -b filename.txt = shows only none-blank lines with numbers
cat filename.txt | head = gives top 10 lines ie head of the file
cat filename1 filename2 > filename3 = merges the files
cat filename1 filename2 >> filename3 = adds contents to another files
cat /etc/fstab = list of all devices
cat /etc/filesystems = of file systems
cat /etc/fedora-release = Fedora release/version no
cat /etc/issue = Linux distro name
cat /var/log/messages | grep -F ntpd =
cat /var/log/wtmp = lists all logins and logouts
cat /run/utmp = lists last reboots and shutdowns
cat /bin/ls | strings = lists all ASCII text in ls

Setting Access ACLs

There are two types of ACLs:

ccess ACLs and default ACLs. An access ACL is the access control list
for a specific file
or directory. A default ACL can only be associated with a directory;
if a file within the directory does not have an access
ACL, it uses the rules of the default ACL for the directory. Default
ACLs are optional.
ACLs can be configured:

1. Per user
2. Per group
3. Via the effective rights mask
4. For users not in the user group for the file

The setfacl utility sets ACLs for files and directories. Use the -m
option to add or modify the ACL of a file or directory:
setfacl -m rules files
Rules (rules) must be specified in the following formats. Multiple
rules can be specified in the same command if they
are separated by commas.

u:uid:perms

Sets the access ACL for a user. The user name or UID may be specified.
The user may be any valid user on the
system.

g:gid:perms

Sets the access ACL for a group. The group name or GID may be
specified. The group may be any valid group on
the system.

m:perms

Sets the effective rights mask. The mask is the union of all
permissions of the owning group and all of the user and
group entries.

o:perms

Sets the access ACL for users other than the ones in the group for the file.
Permissions (perms) must be a combination of the characters r, w, and
x for read, write, and execute.
If a file or directory already has an ACL, and the setfacl command is
used, the additional rules are added to the
existing ACL or the existing rule is modified.
For example, to give read and write permissions to user andrius:

setfacl -m u:andrius:rw /project/somefile

To remove all the permissions for a user, group, or others, use the -x
option and do not specify any permissions:

Setting Default ACLs
To set a default ACL, add d: before the rule and specify a directory
instead of a file name.
For example, to set the default ACL for the /share/ directory to read
and execute for users not in the user group (an
access ACL for an individual file can override it:

setfacl -m d:o:rx /share

Bluetooth Documentation

Browsing files on a remote device
           #> yum install obexftp

Sending SMS/texts via Bluetooth

          #> gnome-phone-manager
Launch the Phone Manager from the System Tools section of the Applications menu.


Sending files via Obex Push
Prerequisites:
      #> gnome-bluetooth
      #> nautilus-sendto
Right-click on a file or files in nautilus and click "Send to...", and select a destination device.


Receiving/Sharing files via ObexFTP and ObexPush
Prerequisites:
      #>gnome-user-share
Select Share Public files over Bluetooth (ObexFTP) or Receive files in Downloads folder over Bluetooth (ObexPush) in the Personal File Sharing preferences.

Bluetooth Devices
 

    #>hcitool scan
     #>hciconfig hci0 up
     #>hciconfig -a
      for more #>lspci

Enjoy! 
by karthik pogunulla



Secure Grub2 with Encrypted Password in Fedora 20

Generate encrypted Grub password using command

#>grub2-mkpasswd-pbkdf2

copy generated encrypted password. like below
----------------------------------------------------------------------
PBKDF2 hash of your password is <grub.pbkdf2.sha512.10000.7970913BCB962B102B8B84CB3290810A6FC267A4319E0041B8E591818BF1FB8C72D252E866464BABAD613756A21157633ED5A5A629786D48A5BD0CCD1C9E92D3.76E22AE403D2C4983261973E9D38311DDC91D58229782C6E5DCAF02F15A1A67AFC34ED4EE82A77ED7EF62DFC3012289AC49526A787F7B66802A3FD391CE2EA34>


edit ---> /etc/grub/grub2.cfg

in First Line paste below lines
----------------------------------------------

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.7970913BCB962B102B8B84CB3290810A6FC267A4319E0041B8E591818BF1FB8C72D252E866464BABAD613756A21157633ED5A5A629786D48A5BD0CCD1C9E92D3.76E22AE403D2C4983261973E9D38311DDC91D58229782C6E5DCAF02F15A1A67AFC34ED4EE82A77ED7EF62DFC3012289AC49526A787F7B66802A3FD391CE2EA34


#### ( ! ) check password hashing is corrctly copied then only Save and Reboot your system.

Sunday, 15 December 2013

NFS -Mount and unmount CIFS and NFS network file systems


CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


NFS

CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


NFS

CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


NFS

CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

NFS -Mount and unmount CIFS and NFS network file systems


NFS

CIFS
# mount -t cifs //server/share /mountpoint -o user=username
#umount /mountpoint
NFS
#mount -t nfs hostname:/mountpoint /mountpoint
#umount /mountpoint
FDISC ( managing partitions )
List, create, delete and set partition type for primary, extended, and logical partitions
List partitions
#fdisk -l
Create partition
#fdisk /dev/vda
(vda can be replaced by sda if its not virtual machine)
Then press
n
After that select e or p for extended or primary partition type.
Then give appropriate size
Finally type
w
Then type
p
to check partition table where you can see the newly created partition.

Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot

Suppose a partition named /dev/sdb1 is available

Now we have to format it with luks
#cryptsetup luksFormat /dev/sdb1

Now partition needs to be labeled
#cryptsetup luksOpen /dev/sdb1 newname

Now format that partition with ext4 or ext3
#mkfs.ext4 /dev/mapper/newname

Now in /etc/crypttab enter
newname /dev/sdb1

Finally in fstab enter
/dev/mapper/newname /mountpoint ext4 defaults 1 2

or if permanent changes are not required then
#mount /dev/mapper/newname /mountpoint
#umount /mountpoint

Configure systems to mount : ext4, LUKS-encrypted and network file systems automatically


Mount ext4 automatically
Open /etc/fstab and enter
/dev/sdb1 /mountpoint ext4 defaults 0 0
Mount LUKS-encrypted automatically
Discussed in
Luks
Mount nfs automatically
Open /etc/fstab and enter
nfsserver:/mount_dir /mountpoint nfs defaults 0 0

Create, delete and modify local groups and group memberships


Create group
#grpadd groupname

Delete group
#groupdel groupname

Add members
#groupadd -G groupname username