On ubuntu, password settings are managed by the pam_unix module, which has a config file located at:
/etc/pam.d/common-password
Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 81 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 82 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 81 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 82
On ubuntu, password settings are managed by the pam_unix module, which has a config file located at:
/etc/pam.d/common-password
Install bridge-utils:
sudo apt-get install bridge-utils
Create a bridge device:
sudo brctl addbr br0
Add interfaces to bridge:
sudo brctl addif br0 eth0 eth1
Bring interfaces down and back up. Remember to bring up the bridge device as well:
sudo ifconfig eth0 down sudo ifconfig eth1 down sudo ifconfig eth0 up sudo ifconfig eth1 up sudo ifconfig br0 up
Finally, to enable internet as well:
ip route add default via <gateway-ip> # If the above command fails, first run dhclient br0
Query your list of devices:
xrandr -q
now set the desired orientation like this:
xrandr --output LVDS1 --rotate right xrandr --output LVDS1 --rotate left xrandr --output LVDS1 --rotate inverted xrandr --output LVDS1 --rotate normal
Replace LVDS1 with the desired screen to rotate.
ssh user@10.99.99.99 -L 0.0.0.0:3333:10.99.99.99:22
This command connects to user at 10.99.99.99. Then, it connects to the local port 22 on 10.99.99.99, and makes it accessible for the remote host at port 3333.
Optionally, the argument ‘-N’ can be supplied, to avoid creating a login shell.
Use the program
gnome-open <my-file>
This will open the file with the default program for that file type, just like when opening files in the graphical environment (nautilus, nemo)
LD_PRELOAD is an environment variable in Linux, which can be used to load a custom shared library, before any other libraries are loaded, during a program startup. This can be used to override functions in standard libraries.
Some user accounts are used for running system services so they cannot interfere with files outside their user space. To create a system account, do the following:
useradd -r <username>
This creates a user with no password, and no home directory. You can optionally create a home dir by supplying the -m option.
useradd -r <username> -m
All upstart scripts must be placed in
etc/init/
and must be owned by root. The script filename must end in .conf
A simple upstart scrip can look like this
start on startup setgid foo setuid foo respawn respawn limit 15 60 exec <my-app>
start on startup
This entry tells upstart to run the application on startup. This can be a run-level specification as well.
setgid foo setuid foo
Sets user and group id if needed.
respawn respawn limit 15 60
Upstart will restart the application if it dies, but will stop if if restarts 15 times within 60 seconds.
Install authbind.
Create a file in
/etc/authbind/byport
with the port-number you wish yo expose. For example, to expose port 80, create the following file:
/etc/authbind/byport/80
Change the user of the file to the user the application is running as, and change the access rights to 755.
Now, run the application like this:
authbind <my-app>
The application now has access to port 80, without requiring sudo rights to run! Authbind can optionally be run with the –deep parameter, to allow all sub-processes access to the port as well.
Example of a self-invoking javascript function. Notice the parenthesis around the entire function declaration.
(function() { var foo = 20; })();
The parenthesis around the function exist to differentiate it from an actual function definition. It would not be possible to auto-invoke it with the () at the end.
Another syntax for self-invoking functions is also available:
! function() { var foo = 20; }();
Again, the ‘!’ is there to show that its not a function declaration.
the i3 window manager comes pre-packaged with a tool called i3-msg, which can be used to send instructions to i3.
For example, if you want to set a vertical tiling of windows, normally you would press “mod + V”. This can be done programmatically like so:
i3-msg split v
Note that the i3-msg is maintains the state that you set. For example, if you want to spawn three windows after setting i3 to vertical splits:
i3-msg split v xterm -e <my-command> xterm -e <my-command2> xterm -e <my-command3>
Useful commands:
i3-msg split v // split vertical i3-msg split h // split horisontal i3-msg workspace 5 // spawn windows at specific workspace i3-msg kill // kill current focused window i3-msg focus parent // switch to containing window
:set list
will show line break characters. ‘$’ denotes \n and ‘^M’ denotes \r.
Change the config option “scroll_speed” to 0, to avoid this issue.
When running make, a lot of information is shown, regarding what directory make is currently in.
This can be disabled by doing this:
make --no-print-directory
CMake prints out a line for every file being compiled, which also shows a progress indicator. This can be disabled with the following flag, when invoking CMake:
cmake -DCMAKE_RULE_MESSAGES=NO CMakeLists.txt
cat myFile - | nc 127.0.0.1 1234
cat will echo the file to stdout, which will cause nc to pick it up and send it. We add the ‘-‘ to cat, to keep it reading from stdin, which will cause nc to keep the connection alive, because it expects more data to be sent.
git fsck --lost-found
Example of useful content in the .gitconfig gile
[alias] st = status -sb br = branch ca = commit -a p = push pt = push --tags co = checkout subub = submodule update --init --recursive merge = merge --no-ff ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate diff = diff --word-diff find = "!git ls-files | grep -i" f = "!git ls-files | grep -i" grep = grep -Ii gr = grep -Ii [user] name = John Doe email = user@foo.com [color] diff = auto status = auto branch = auto [core] editor = vim [push] default = tracking
A shell script can have a binary payload attached to it, that it can extract from itself.
Say for example that you have the following shell script format:
<some shell commands> PAYLOAD: <some payload>
The “PAYLOAD:” is a line, with ONLY that written on it. This is a marker, used to find the binary payload later on.
Imagine that we create the following script to append binary payloads to a shell script:
cat install.sh.in > install.sh echo "PAYLOAD:" >> install.sh cat $1 >> install.sh
The above script will create a new file install.sh from the install.sh.in template (makes it easier to test the script, because you do not have to rewrite install.sh everytime :))
Then the PAYLOAD: line is appended, and finally, whatever was given as an argument ($1 is the first argument to the script. $0 is the script itself) is appended.
Now we can create the install.sh.in script:
#First we find the linenumber which holds the marker-text #We do this by grepping in text mode (-a) and we want line numbers printed (-n) #and we grep on the script itself ($0). We then pipe this to the cut command, which splits #the output from grep on the ':' character. Then we extract the first entry from the split (-f #1). This should give us the line number. match=$(grep -a -n '^PAYLOAD:$' $0 | cut -d ':' -f 1) #The payload starts AFTER the PAYLOAD marker payload_start=$((match+1)) #Now we can extract the binary part of the script itself, using the tail command. #'-n +' means "start from line number. As a demo we pipe the binary data #to tar to show the files inside. (given that the binary payload was a tar to begin #with!) tail -n +$payload_start $0 | tar -zt #remember to exit before the payload! Otherwize the binary payload will be #interpreted as script. exit 0