Last active
October 14, 2015 00:57
-
-
Save terryoy/4282588 to your computer and use it in GitHub Desktop.
A Collection of Shell Scripts/Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert text files to all lower case | |
$ tr '[:upper:]' '[:lower:]' < input.txt > output.txt | |
# Convert Data Stored in a Shell Variable From UPPPER to lowercase | |
$ echo $VAR_NAME | tr '[:upper:]' '[:lower:]' | |
# Convert Data Stored in a Shell Variable From lowercase to UPPER | |
$ echo $VAR_NAME | tr '[:lower:]' '[:upper:]' | |
# job control: | |
# ctrl+z - suspend a job and put into background | |
# fg - brings a background job | |
fg | |
# bg - list all the background jobs | |
# jobs - list all the background/foreground jobs, (-l to list with pid) | |
jobs -l | |
# add launchpad apps to ubuntu software sources | |
sudo add-apt-repository ppa:<user>/<ppa-name> | |
## curl for HTTP requests ### | |
curl -D - -X POST -d "key=value&key1=value1" http://localhost/someurl | |
# "-D -" is dump response header to a file, "-" meaning to console | |
# "-X POST" is set request method | |
# "-d" or "--data is for post request data, alternatives: | |
# "-d @file" - the request content is in the file | |
# "--data-ascii" - default | |
# "--data-binary key@binaryfile" - raw data that loads binary file of "binaryfile" as for key "key" | |
### User & Group ### | |
# add user to an existing group | |
usermod -a -G ftp terryoy | |
# change user's primary group | |
usermod -g www terryoy | |
# create user with primary group | |
useradd -g developers terryoy | |
# check user's group | |
id terryoy | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# script to mount a virtualbox vdi file to a path | |
# e.g.: sudo ./mount.sh xxx.vdi vdisk | |
mkdir .$2 | |
vdfuse -raf $1 .$2 | |
mkdir $2 | |
mount .$2/Partition1 $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# the script unmount and remove the vdisk which works together with mount.sh | |
# e.g.: sudo ./unmount.sh vdisk | |
umount $1 | |
umount .$1 | |
rm -ir $1 .$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment