Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sharing Folder from Mac to Cent OS VM

Install VMware Tools

  1. Start up VM.
  2. Goto Virtual Machine -> Install VMware Tools
  3. There will be a pop up window. Click Install to connect the VMware Tools installer CD to this virtual machine.
  4. From the CD, Extract the VMwareTools-<version>.tar.gz
  5. Goto the folder
  6. Run the following command:
./vmware-install.pl -d --clobber-kernel-modules=vmhgfs

Share a Folder

  1. Goto Virtual Machine -> Settings
  2. In the pop up window choose Sharing
  3. Check the Enable Shared Folders option
  4. Click [+]  and select the folder on Mac which is to be shared
  5. The folder will be visible under /mnt/hgfs/

Vim - Highlight OverLength


Add the following code to /etc/vimrc if we want to highlight the characters that go beyond column 80.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+ 

Clearing OS cache

Run the following command as root
echo 3 > /proc/sys/vm/drop_caches

Find the list of directories with their Sizes

Get Size of all sub-directories

Command: 
du -sh <directory_path>/*

Example:
$ du -sh /home/Beena/*

4.0K /home/Beena/Desktop
4.0K /home/Beena/Documents
64M /home/Beena/Downloads
4.0K /home/Beena/Music
4.0K /home/Beena/Pictures
4.0K /home/Beena/Public
4.0K /home/Beena/Templates
4.0K /home/Beena/Videos


Get all files and sub-directories More than a specified size

Command: 
find <dir_path> -size +<size> -ls

Example:
find /home/Beena/ -size +10M -ls


Get all files and sub-directories Less than a specified size

Command: 
find <dir_path> -size -<size> -ls

Example:
find /home/Beena/ -size -10M -ls


Linux Users

List users

$ cat /etc/passwd | grep "/home"
Beena:x:500:500:Beena Emerson:/home/Beena:/bin/bash

Only list names:
$ cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1
Beena

Add New User

You have to be root user to be able to add new users.
# useradd test_user
# cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1
Beena
test_user
Switch Users:
# su test_user
[test_user@localhost ~]$

Add Password

# passwd test_user
Changing password for user test_user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Delete User

# userdel test_user
# cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1
Beena