Check These Out
You have an external USB drive or key.
Apply this command (using the file path of anything on your device) and it will simulate the unplug of this device.
If you just want the port, just type :
echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-")
When dealing with system resource limits like max number of processes and open files per user, it can be hard to tell exactly what's happening. The /etc/security/limits.conf file defines the ceiling for the values, but not what they currently are, while
$ ulimit -a
will show you the current values for your shell, and you can set them for new logins in /etc/profile and/or ~/.bashrc with a command like:
$ ulimit -S -n 100000 >/dev/null 2>&1
But with the variability in when those files get read (login vs any shell startup, interactive vs non-interactive) it can be difficult to know for sure what values apply to processes that are currently running, like database or app servers. Just find the PID via "ps aux | grep programname", then look at that PID's "limits" file in /proc. Then you'll know for sure what actually applies to that process.
Using this command you can track a moment when usb device was attached.
Normally, if you su to another user from root and try to resume that other user's screen session, you will get an error like "Cannot open your terminal '/dev/pts/0' - please check." This is because the other user doesn't have permission for root's pty. You can get around this by running a "script" session as the new user, before trying to resume the screen session. Note you will have to execute each of the three commands separately, not all on the same line as shown here.
Credit: I found this at http://www.hjackson.org/blog/archives/2008/11/29/cannot-open-your-terminal-dev-pts-please-check.
-n reads input, line by line, in a loop sending to $_ Equivalent to while () { mycode }
-e execute the following quoted string (i.e. do the following on the same line as the perl command)
the elipses .. operator behaves like a range, remembering the state from line to line.
Find the usage of a switch with out searching through the entire man page.
Usage: manswitch [cmd] [switch]
Eg:
$manswitch grep silent
____________________________
In simple words
$man | grep "\-"
Eg:
$man grep | grep "\-o"
This is not a standard method but works.
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
This will make your bash scripts better!!
process-getopt is a wrapper around getopt(1) for bash that lets you define command line options (eg -h, --help) and descriptions through a single function call. These definitions are then used in runtime processing of command line options as well as in generating help and man pages. It also saves a little time in coding and in producing nicely formatted documentation. It is quite similar to GNU's argp in glibc for compiled languages and OptionParse for python.
See: Linux Gazette article 162: http://tldp.org/LDP/LGNET/162/hepple.html,
http://sourceforge.net/projects/process-getopt, http://bhepple.freeshell.org/oddmuse/wiki.cgi/process-getopt
This is a funny usage of the traditional command ls.
It could be basically simplified as:
$ ls -a -l
Duplicating arguments is permitted:
$ ls -a -l -l
And this markup could be shortened as:
$ ls -al
Extra note:
To view filesizes like a pro, pray for your God:
$ ls -allah