Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Last active November 16, 2015 22:10
Show Gist options
  • Save aimtiaz11/9d12bf3986f738d5eea9 to your computer and use it in GitHub Desktop.
Save aimtiaz11/9d12bf3986f738d5eea9 to your computer and use it in GitHub Desktop.
Useful UNIX Commands

Extracting Lines from File

Between 2 line intervals:

 sed -n 2601,2700p 8k_users.csv > logins27.csv

User Management

#####Add New User

useradd -d /home/jsmith jsmith

Edit the /etc/password as root user and edit the entry for the new user. Update with the full name

jsmith:x:507:507:John Smith:/home/jsmith:/bin/bash

#####Force new user to change password on next login:

chage -d 0 jsmith
```````````

Edit the ``/etc/default/useradd`` file and set the ``EXPIRE=0`` to force all new users to change password by default when using the ``useradd`` command.


Find all files owned by user
````
find . -user l046240
````

To remove a user, use the command:
````
userdel -r l046240
````

Adding Windows File System in mount point

mount -t cifs -o username=aimtiaz,password=xxxx //WINSERVER/WE04 /windowsbackup

Setting up VNC

Setup VNC Server:

yum install tigervnc-server

Edit the vncserver config file:

vi /etc/sysconfig/vncservers

Add username:

[...]
VNCSERVERS="2:weblogic 3:aimtiaz"
VNCSERVERARGS[2]="-geometry 1200x1024 -nolisten tcp -localhost"

Login as the user you want VNC in as and then set the password using vncpasswd command.

Adding Gnome/KDE

yum groupinstall "Development Tools"
yum groupinstall "X Window System" "Desktop"
yum groupinstall "GNOME Desktop Environment"

Using find

  • Find files and copy to a directory
 find . -name "*.jar" -exec cp -rfp {} ~/Documents/workspace2/com.vogella.jersey.first/WebContent/WEB-INF/lib/ \;

Soft Link

ln -s /usr/tmp/realfile some_link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment