Skip to content

Instantly share code, notes, and snippets.

@adeleinr
Created April 16, 2010 05:49
Show Gist options
  • Save adeleinr/368076 to your computer and use it in GitHub Desktop.
Save adeleinr/368076 to your computer and use it in GitHub Desktop.
Linux Commands Cheatsheet
#Big grep
find Members/ -type f -print0 | xargs -0 grep "examplestring"
#grep line plus its context (1 line before 3 lines after)
grep -A 3 -B 1 “patter” filename
#10 biggest files in a directory
du -a /var | sort -n -r | head -n 10
#Get a column from a file
cut -f 3 -d, filename
#(tee => read from standard input and write to standard output and files)
tail -f out | tee file.out
#Create user
useradd -g users -d /home/karim -s /bin/bash -c temporary -e 2006-06-30 -m karim
-g (user initial group) - users
-d (user's home directory when login) - /home/karim
-s (user's shell) - /bin/bash
-c (comment) - Temporary
-e (account expired date) - 2009-11-30
-m (create user's home directory)
karim (username of the new account)
#Change user password
passwd karim
#Edit user info
Edit /etc/passwd
karim:x:1003:100:temporary:/home/karim:/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment