install-free,
run standalone.
Friday, October 19, 2012
Wednesday, October 17, 2012
Non-interactive command lines to create Linux user, and change password
Non-interactive command lines to create Linux user, and change his password.
1. create user and home folder etc.
2. change password.
adduser jenkins --disabled-password --gecos ""
echo "jenkins:the_new_password"|chpasswd
http://askubuntu.com/questions/94060/run-adduser-non-interactively
http://www.linuxquestions.org/questions/linux-newbie-8/non-interactive-way-to-set-a-password-825627/
2
man adduser
http://linux.die.net/man/8/adduser
CLEAR MANUAL PAGE OF ALL CMD LINE SWITCHES
http://linux.about.com/od/commands/l/blcmdl8_adduser.htm
MORE CLEAR
http://www.cyberciti.biz/faq/howto-linux-add-user-use-adduser-command/
3
View all users in linux
cat /etc/passwd
http://www.omnisecu.com/gnu-linux/redhat-certified-engineer-rhce/linux-user-database.htm
Types of linux users
http://www.omnisecu.com/gnu-linux/redhat-certified-engineer-rhce/introduction-to-linux-user-administration.htm
1. create user and home folder etc.
2. change password.
adduser jenkins --disabled-password --gecos ""
echo "jenkins:the_new_password"|chpasswd
http://askubuntu.com/questions/94060/run-adduser-non-interactively
http://www.linuxquestions.org/questions/linux-newbie-8/non-interactive-way-to-set-a-password-825627/
2
man adduser
http://linux.die.net/man/8/adduser
CLEAR MANUAL PAGE OF ALL CMD LINE SWITCHES
http://linux.about.com/od/commands/l/blcmdl8_adduser.htm
MORE CLEAR
http://www.cyberciti.biz/faq/howto-linux-add-user-use-adduser-command/
3
View all users in linux
cat /etc/passwd
http://www.omnisecu.com/gnu-linux/redhat-certified-engineer-rhce/linux-user-database.htm
Types of linux users
http://www.omnisecu.com/gnu-linux/redhat-certified-engineer-rhce/introduction-to-linux-user-administration.htm
Sunday, October 14, 2012
Friday, October 12, 2012
Shell script exit status
http://www.thegeekstuff.com/2010/03/bash-shell-exit-status/
In our bash introduction article, we learned that a shell-script file contains list of commands to be executed by the shell interpreter. In this article let us review about shell commands and its internals.
A command is a sequence of words. The first word indicates the command to be executed and remaining words are passed as an arguments, where arguments could be the options or parameters to the command.
Some of the common Unix commands you execute at the command line are shell commands. For example, ls, lpr and grep command.
Some of the common Unix commands you execute at the command line are shell commands. For example, ls, lpr and grep command.
$ ls -alF $ lpr filename $ grep "string" filename
Shell Command Exit Status
The return value of a command is its exit status, or 128 + N if the command is terminated by signal N. Exit status is used to check the result (success/failure) of the execution of the command. If the exit status is zero, then the command is success. If the command is failed the exit status will be non-zero.
| Exit Value | Exit Status |
|---|---|
| 0 (Zero) | Success |
| Non-zero | Failure |
| 2 | Incorrect usage |
| 127 | Command Not found |
| 126 | Not an executable |
$? Shell Variable
The shell variable name $? is a special built-in variable which has the exit status of the last command executed.
- After the shell function execution, $? returns the exit status of the last command executed in a function.
- After the shell script execution, $? returns the exit status of the last command executed in the script.
Sample Shell Script that Explains Shell-Command Exit Status
The following exitstatus.sh shell-script shows examples of various shell-command exit status.
$ cat exitstatus.sh #! /bin/bash echo -e "Successful execution" echo -e "=====================" echo "hello world" # Exit status returns 0, because the above command is a success. echo "Exit status" $? echo -e "Incorrect usage" echo -e "=====================" ls --option # Incorrect usage, so exit status will be 2. echo "Exit status" $? echo -e "Command Not found" echo -e "=====================" bashscript # Exit status returns 127, because bashscript command not found echo "Exit status" $? echo -e "Command is not an executable" echo -e "=============================" ls -l execution.sh ./execution.sh # Exit status returns 126, because its not an executable. echo "Exit status" $?
Now, execute the above exitstatus.sh to see the various exit statues given by the sample shell script.
$ bash exitstatus.sh Successful execution ===================== hello world Exit status 0 Incorrect usage ===================== ls: unrecognized option `--option' Try `ls --help' for more information. Exit status 2 Command Not found ===================== exitstaus.sh: line 15: bashscript: command not found Exit status 127 Command is not an executable ============================= -rw-r--r-- 1 root root 659 Mar 9 13:36 execution.sh exitstatus.sh: line 21: ./execution.sh: Permission denied Exit status 126
Note: Checking the return value of a function or a command is one of the main responsibility of a programmer. This should become your second nature while writing any code.
JSON " for strings, with neat diagrams
http://www.json.org/
http://stackoverflow.com/questions/4162642/python-single-vs-double-quotes-in-json
http://stackoverflow.com/questions/242813/when-to-use-double-or-single-quotes-in-javascript
which is easier to read? alert("It's game time"); or alert('It\'s game time'); – Ryan Miller Jun 9 '11 at 16:10
| 33 |
How about this Ryan?
alert("It's \"game\" time."); or alert('It\'s "game" time.');? – Francisc Oct 11 '11 at 18:37| 3 |
If single quotes always used and occasionally double quotes where the literal contains single quote, then we will have to type far less shift buttons and our left little finger will give us blessings. But yes, as @arne said, for JSON double quote should be used. – iSid Oct 31 '11 at 15:46
| 1 |
Single quoting is easier to do when you're on a european keyboard (double quote is Shift+2 which isn't as sweet as tapping a single key conveniently by your right pinky). – Arne Apr 25 at 20:46
| 1 |
@Arne There is no such a thing as an "European keyboard". E.g. the German keyboard requires shift for both types of quotes. (But single quotes are easier.) – ANeves Jun 18 at 15:53
MySQL COMMANDS and EXPRESSIONS
http://dev.mysql.com/doc/refman/5.0/en/expressions.html
http://dev.mysql.com/doc/refman/5.0/en/functions.html
Chapter 12. Functions and Operators
Table of Contents [+/-]
- 12.1. Function and Operator Reference
- 12.2. Type Conversion in Expression Evaluation
- 12.3. Operators [+/-]
- 12.4. Control Flow Functions
- 12.5. String Functions [+/-]
- 12.6. Numeric Functions and Operators [+/-]
- 12.7. Date and Time Functions
- 12.8. What Calendar Is Used By MySQL?
- 12.9. Full-Text Search Functions [+/-]
- 12.10. Cast Functions and Operators
- 12.11. Bit Functions
- 12.12. Encryption and Compression Functions
- 12.13. Information Functions
- 12.14. Miscellaneous Functions
- 12.15. Functions and Modifiers for Use with
GROUP BYClauses [+/-] - 12.16. Spatial Extensions [+/-]
- 12.17. Precision Math [+/-]
Expressions can be used at several points in SQL statements, such as in the
ORDER BY or HAVING clauses of SELECTstatements, in the WHERE clause of a SELECT, DELETE, orUPDATE statement, or in SET statements. Expressions can be written using literal values, column values, NULL, built-in functions, stored functions, user-defined functions, and operators. This chapter describes the functions and operators that are permitted for writing expressions in MySQL. Instructions for writing stored functions and user-defined functions are given in Section 18.2, “Using Stored Routines (Procedures and Functions)”, and Section 21.2, “Adding New Functions to MySQL”. See Section 9.2.3, “Function Name Parsing and Resolution”, for the rules describing how the server interprets references to different kinds of functions.
An expression that contains
NULL always produces a NULLvalue unless otherwise indicated in the documentation for a particular function or operator.
Note
By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted.
EXPRESSIONS SYNTAX:
expr:exprORexpr|expr||expr|exprXORexpr|exprANDexpr|expr&&expr| NOTexpr| !expr|boolean_primaryIS [NOT] {TRUE | FALSE | UNKNOWN} |boolean_primaryboolean_primary:boolean_primaryIS [NOT] NULL |boolean_primary<=>predicate|boolean_primarycomparison_operatorpredicate|boolean_primarycomparison_operator{ALL | ANY} (subquery) |predicatecomparison_operator: = | >= | > | <= | < | <> | !=predicate:bit_expr[NOT] IN (subquery) |bit_expr[NOT] IN (expr[,expr] ...) |bit_expr[NOT] BETWEENbit_exprANDpredicate|bit_exprSOUNDS LIKEbit_expr|bit_expr[NOT] LIKEsimple_expr[ESCAPEsimple_expr] |bit_expr[NOT] REGEXPbit_expr|bit_exprbit_expr:bit_expr|bit_expr|bit_expr&bit_expr|bit_expr<<bit_expr|bit_expr>>bit_expr|bit_expr+bit_expr|bit_expr-bit_expr|bit_expr*bit_expr|bit_expr/bit_expr|bit_exprDIVbit_expr|bit_exprMODbit_expr|bit_expr%bit_expr|bit_expr^bit_expr|bit_expr+interval_expr|bit_expr-interval_expr|simple_exprsimple_expr:literal|identifier|function_call|simple_exprCOLLATEcollation_name|param_marker|variable|simple_expr||simple_expr| +simple_expr| -simple_expr| ~simple_expr| !simple_expr| BINARYsimple_expr| (expr[,expr] ...) | ROW (expr,expr[,expr] ...) | (subquery) | EXISTS (subquery) | {identifierexpr} |match_expr|case_expr|interval_expr
Notes:
For literal value syntax, see Section 9.1, “Literal Values”.
For identifier syntax, see Section 9.2, “Schema Object Names”.
Variables can be user variables, system variables, or stored program local variables or parameters:
- User variables: Section 9.4, “User-Defined Variables”
- System variables: Section 5.1.5, “Using System Variables”
- Local variables: Section 13.6.4.1, “Local Variable
DECLARESyntax”
param_marker is '?' as used in prepared statements for placeholders. See Section 13.5.1, “PREPARESyntax”.(subquery) indicates a subquery that returns a single value; that is, a scalar subquery. SeeSection 13.2.9.1, “The Subquery as Scalar Operand”.{identifier expr} is ODBC escape syntax and is accepted for ODBC compatibility. The value isexpr. The curly braces in the syntax should be written literally; they are not metasyntax as used elsewhere in syntax descriptions.interval_expr represents a time interval. The syntax is INTERVAL expr unit, where unit is a specifier such as HOUR, DAY, or WEEK. For the full list of unit specifiers, see the description of theDATE_ADD() function in Section 12.7, “Date and Time Functions”.
The meaning of some operators depends on the SQL mode:
- By default,
||is a logicalORoperator. WithPIPES_AS_CONCATenabled,||is string concatenation, with a precedence between^and the unary operators. - By default,
!has a higher precedence thanNOTas of MySQL 5.0.2. For earlier versions, or from 5.0.2 on withHIGH_NOT_PRECEDENCEenabled,!andNOThave the same precedence.
Subscribe to:
Posts (Atom)