[131012370010] |
less
and man
(which uses less
) will have color:
[131012400040] |And then in my ~/.bashrc, I do this:
[131012410010] |export PAGER=most
[131012420010] |R
command brings you into an interactive programming environment, which is fine if you're trying to work out how to do something by hand or are building something up incrementally, but from your question, it sounds like you just need a list of numbers to send to another program.
[131012440050] |So instead, we use Rscript
, which behaves more like a traditional Unix script interpreter: you can pass it the name of a file containing an R script, or use the standard -e
flag to pass the entire program text on the command line.
[131012440060] |rnorm()
is the R function to get a list of random numbers with the "normal" or Gaussian distribution.
[131012440070] |It takes up to three parameters, only the first of which is required, how many numbers you want.
[131012440080] |We've asked for 100.
[131012440090] |By taking the defaults for the other two optional parameters, we get a mean of 0 and a standard deviation of 1.
[131012440100] |The arithmetic after that is just showing off a cool feature of the R language: you can do arithmetic on whole data tables, matrices, etc., just as easily as a scalar value in a more typical language.
[131012440110] |I've multiplied all generated values by 100 and added 100 to them, just because I can.
[131012440120] |Because R is a full-fledged programming language, there's no limit to the things you could do with this list of numbers.
[131012440130] |That's the advantage of using such a system instead of a fixed-purpose command like jot
.
[131012440140] |We pass the result of that previous operation to the write()
function, which writes the data out to a file by default, but we've overridden that by passing a blank string for the second parameter, the file name, so it writes the table out to the terminal instead.
[131012440150] |The next parameter, 1
, just tells it we want our output in single-column format.
[131012440160] |R has many other random number generation functions built into the base system.
[131012440170] |For instance, we can mimic the jot
command in lcpriani's answer with this script:
[131012440180] |Here we're using runif()
to get 10 uniformly-distributed random numbers from 12 to 27.
[131012440190] |Like rnorm()
, which we used above, this function returns floating-point values, so we have to round()
them to their nearest integer values before writing them to the screen.
[131012440200] |R also has a rich set of add-ons in CRAN, a package repository modeled on Perl's CPAN.
[131012440210] |One you might be interested in is simply called random, which acts as an interface to random.org, a service that returns true random numbers generated from atmospheric noise.
[131012440220] |R is a complete programming environment, so it may be that you don't actually need to get your numbers out of R in text format.
[131012440230] |You might be able to solve your problem entirely in R. Give it a shot.
[131012450010] |-i
switch will save your old file with a .old
extension and print to the current one.
[131012500010] |You can also use "ex" (command-line vi) if the editing you want to do is even somewhat complicated.
[131012500020] |For example, you only want to do the insert for on one instance of "".
[131012500030] |C:
but it deleted first secondary partition (/dev/sda5
).
[131012560090] |Strangely grub was left on its place and data was undamaged (fortunatly I could reverse-engeneer the positions).at
-command, but as far as I could understand it's only possible specify minutes (and not seconds).
[131012620040] |Right now I first use at
and then sleep
to get it to execute the right second.
[131012620050] |To demonstrate, if I would like to run my_script.sh at 22.21.05 I would do:
[131012620060] |But it would be much nicer to have a command with it built in. Something like at 22.21.05
.
[131012630010] |I don't believe that this is possible. cron
is only granular down to the minute and the at
utility hooks into it to do it's work.
[131012630020] |I think you have the right solution--sleeping for x seconds before executing.
[131012640010] |You could make your technique into a function:
[131012640020] |Try it out:
[131012640030] |You should be aware, however, that precision is not guaranteed.
[131012650010] |/lib/udev/rules.d/80-udisks.rules
has some default rules that make udisks ignore some partitions (e.g. partitions that are known to be rescue partitions etc.) which might be an inspiration...
[131012660030] |On Ubuntu 10.04 your own rules should go into /etc/udev/rules.d/
(see the README there).
[131012660040] |After some experimenting, the following seems to work:
[131012660050] |Put that line in a *.rules file that has a name that lexically follows the rules file that contains the normal udisk-related rules.
[131012660060] |Easiest to do that is to start it with a higher number (so I used 81 to make sure it overrides the rules in 80-*).
[131012660070] |Of course use whatever UUID your partition has.
[131012660080] |On another distro those things might be located differently, but the basics should be the same...
[131012670010] |search
can contain \n
s to represent newlines
[131012690010] |OVM reboot
probably mean to reboot the virutal machine from Oracle VM Manager.
[131012760010] |thisismyfolder912
than having to do a
[131012780040] |What is that way and how does it work?
[131012780050] |Also, what are the other ways I can use this?
[131012790010] |Are you talking about classic history expansion, or Readline processing? cd !$
on the next input line will substitute in the last argument of the previous line, or M-. or M-_ will yank it using Readline.
[131012800010] |It's as simple as Alt + .
[131012800020] |Alt + .
[131012810010] |If your question is about accessing command history, then try this well-named command
[131012810020] |You can also try Ctrl + r, and start typing a command you're trying to remember that you've recently typed.
[131012810030] |Hit ESC to select the command or exit.
[131012810040] |This works for me on SuSE at least; not sure about other distros.
[131012820010] |If you use bash i suggest pushd
and popd
.
[131012820020] |You can create a stack of directory and browse it rapidly.
[131012820030] |See this example:
[131012830010] |this has always worked for me:
[131012840010] |Picking up a tip from another thread, if you put:
[131012840020] |in your .bashrc then, you can start typing something from your history, and then press the up arrow, and then rather than going through your history item by item, it'll skip right to previous entries that begin with what you've already typed.
[131012840030] |I guess this doesn't help much with the particular example given in the question, but it is one thing that helps me access history on the fly.
[131012850010] |What About pressing ATL+.
together.So you can iterate through all the previous command
[131012860010] |On a related note, I recommend using histverify in bash.
[131012860020] |Put this in your ~/.bashrc:
[131012860030] |This will cause bash to print out the command after expanding !$ or other history functions, and give you a chance to look at it before hitting enter again to actually run it.
[131012860040] |For me, the sanity check is worth the occasional extra key press.
[131012860050] |Want to make sure I'm running the cd foo
command, not the rm -rf foo
one...
[131012860060] |I frequently use the Ctrl-R approach, as well as Alt-. (which is a good fit for the scenario you describe).
[131012860070] |I'll use !$ on occasion.
[131012860080] |These are very useful general purpose techniques.
[131012860090] |But to address your specific question:
[131012860100] |Making a directory and cd'ing directly into it is such a common combination that it is useful to have a function to wrap it up..
[131012860110] |Usage: mcd thisismyfolder
[131012870010] |wheel
group on *nix computers typically refers to the group with some sort of root-like access.
[131012870030] |I've heard that on some *nixes it's the group of users with the right to run su
, but on Linux that seems to be anyone (although you need the root password, naturally).
[131012870040] |On Linux distros I've used it seems to be the group that by default has the right to use sudo
; there's an entry in sudoers
for them:
[131012870050] |But that's all tangential; my actual question is: Why is this group called wheel
?
[131012870060] |I've heard miscellaneous explanations for it before, but don't know if any of them are correct.
[131012870070] |Does anyone know the actual history of the term?
[131012880010] |Wikipedia knows it?
[131012880020] |The term is derived from the slang term big wheel, referring to a person with great power or influence
[131012890010] |It comes to us from BSD.
[131012890020] |This is verifiable.
[131012890030] |But where did it begin?
[131012890040] |Here is a non-verifiable explanation- BSD got it from the TOPS-20 O/S.
[131012890050] |http://lists.freebsd.org/pipermail/freebsd-chat/2003-December/001725.html
[131012900010] |The Jargon File has an answer which seems to agree with kmarsh.
[131012900020] |wheel: n. [from slang ‘big wheel’ for a powerful person] A person who has an active wheel bit...The traditional name of security group zero in BSD (to which the major system-internal users like root belong) is ‘wheel’...
[131012900030] |A wheel bit is also helpfully defined:
[131012900040] |A privilege bit that allows the possessor to perform some restricted operation on a timesharing system, such as read or write any file on the system regardless of protections, change or look at any address in the running monitor, crash or reload the system, and kill or create jobs and user accounts.
[131012900050] |The term was invented on the TENEX operating system, and carried over to TOPS-20, XEROX-IFS, and others.
[131012900060] |The state of being in a privileged logon is sometimes called wheel mode.
[131012900070] |This term entered the Unix culture from TWENEX in the mid-1980s and has been gaining popularity there (esp. at university sites).
[131012910010] |AFAIK, this is not the derivation, but ...
[131012910020] |wheel
is for real people, whereas users
is for losers.
[131012910030] |At least that's the way some Unix sysadm's think :-).
[131012920010] |As others have said, it comes from the term "Big Wheel".
[131012920020] |I think many of us are not familiar with this term because, according to at least one site, it became a popular expression after World War Two:
[131012920030] |Big wheel is another way to describe an important person.
[131012920040] |A big wheel may be head of a company, a political leader, a famous doctor.
[131012920050] |They are big wheels because they are powerful.
[131012920060] |What they do affects many persons.
[131012920070] |Big wheels give the orders.
[131012920080] |Other people carry them out.
[131012920090] |As in many machines, a big wheel makes the little wheels turn.
[131012920100] |Big wheel became a popular expression after World War Two.
[131012920110] |It probably comes from an expression used for many years by people who fix the mechanical parts of cars and trucks.
[131012920120] |They said a person "rolled a big wheel" if he was important and had influence.
[131012920130] |For those like me who were born in the 1980s, we may find the following a closer cultural reference for a Big Wheel:
[131012930010] |wget
with the option --recursive
.
[131012940020] |But be aware that it could download a lot of sites :) .
[131012940030] |To limit the result you could also use the the argument --domains=domain-list
if you only want sites from a specific domain (or several domains separated by commas) and the --level=depth
-argument to specify the level of recursion.
[131012940040] |So, your command could look something like this:
[131012940050] |But there's a lot more options to wget
.
[131012940060] |Check out the man page for wget.
[131012950010] |Checkout App::SD on your local CPAN.
[131012950020] |SD is a peer to peer bug tracking system which we've built to share with just about anything.
[131012950030] |Contributors have helped us write adaptors for RT, Hiveminder, Trac, GitHub, Google Code, and Redmine.
[131012950040] |You can extend SD to sync to other bug tracking tools by writing a small bit of code.
[131012950050] |If you can help make SD work better with your bug tracker, drop us a line.
[131012950060] |update I just realized that list doesn't yet include Bugzilla... sorry. but I'm gonna leave the answer up in the event that it does in the future, or someone wants to use if for offline caching of another bugtracker, or maybe you want to add bugzilla support.
[131012960010] |As this would cover any Bugzilla installation I wonder if there is a recommend way upstream for this.
[131012970010] |(void)signal(SIGHUP, SIG_IGN);
// Ignore SIGHUP
[131012990030] |execvp(*argv, argv);
// Run the command.
[131012990040] |So until your application calls something like
[131012990050] |signal (SIGHUP, SIG_DFL);
//OR some custom signal handler
[131012990060] |In the normal circumstances it will continue to run until you restart machine or kill it yourself.
[131012990070] |It might also be terminated in the cases pointed by kmarsh.
[131013000010] |/etc/pam.d/sshd
) but I'm not certain on the details.
[131013000100] |How can I set up authentication where two methods are required?
[131013010010] |Assuming this uses pam, it should be as simple as putting two required modules in /etc/pam.d/.
[131013010020] |One for Opie, and one for your other auth. (say, normal UNIX password)
[131013020010] |Since you want to use a password that is something other than the one for your normal account, try security/pam_pwdfile from the ports tree.
[131013020020] |Basically, it allows you to use an alternate file (format: "username:crypted_password") to authenticate against.
[131013020030] |To use it put the following line in /etc/pam.d/sshd right before the line for pam_opie:
[131013020040] |auth required /usr/local/lib/pam_pwdfile.so pwdfile /path/to/pwd/file
[131013030010] |-R
option.
[131013030030] |From man screen
:
[131013030040] |However, when I run screen -R
it does not actually attach to the youngest detached session.
[131013030050] |Instead, it complains that there are "several suitable screens" and that I need to choose one of them.
[131013030060] |Am I missing something?
[131013030070] |How do I make this work as advertised?
[131013040010] |Try using screen -RR
.
[131013040020] |Example:
[131013040030] |Note that screen 5958 is the youngest.
[131013040040] |Using screen -RR
connects to screen 5958.
[131013040050] |The -RR
options is somewhat further explained in the documentation for -d -RR
.
[131013040060] |Another trick I often use is to use -S
to give the screen a tag/label.
[131013040070] |Then you can reattach using that tag without having to remember what was happening in each screen if the list gets unwieldy.
[131013040080] |Example (Launch screens for vim and curl):
[131013040090] |Note: The -dm
option was just used to start a detached screen
[131013040100] |And then, at a later date, you can easily reconnect using the tag curl
.
[131013050010] |I use screen -R in gnome-terminal and, as you said, if 2 sessions are running at the same time, then gnome-terminal quits immediately.
[131013050020] |I solved it by running
[131013050030] |this works just as you expect.
[131013060010] |split
or ed
, awk
or any programming language.
[131013110010] |Use a tool that gives you access to the truncate
system call.
[131013110020] |You can do it with only POSIX tools.
[131013110030] |Warning, typed into a browser; be especially careful as dd
is even more unforgiving of errors than the usual unix command.
[131013110040] |123456 is the number of bytes to keep.
[131013110050] |A Perl version is much more readable:
[131013120010] |*
.
[131013120040] |This is used for system users such as users for databases like mysql, pgsql etc.
[131013120050] |What's nice about this is that these users doesn't show up at the login screen and you can't login as them without sudo etc.
[131013120060] |After deleting such a user trying some things out I wanted to recreate it, but couldn't.
[131013120070] |I could manage to get a user with a blank password and I could set the password to *.
[131013120080] |But none had the same effect as above, as the user showed up on my login screen.
[131013120090] |How do you create such a user?
[131013130010] |If you are on Ubuntu you can swap in the password for the Ubuntu user in /etc/shadow/ check out this article:
[131013130020] |http://www.psychocats.net/ubuntucat/creating-a-passwordless-account-in-ubuntu/
[131013140010] |A user in /etc/passwd with home directory of /dev/null and shell of /sbin/nologin, can be used for sudo ing commands, but can't actually be logged into, for example;
[131013140020] |from my /etc/passwd
[131013140030] |I half remember this will make it disappear from the XDM login screen too, but I don't use XDM anymore, so that's a guess :-)
[131013150010] |You can run passwd --delete -
passed to the -h
option tells pw
to set the password field in master.passwd to *
, thus creating a no-login account.
[131013160030] |Setting the shell isn't strictly necessary, but avoids a shell check from /etc/pw.conf.
[131013170010] |-f
parameter, output is passed to stdout:
[131013200030] |...what a mess!
[131013200040] |The -f
-parameter (as you quoted) expects a filename (and optionally a hostname), hence the first argument after it is the output filename:
[131013210010] |ls
in one, switch to another already-running terminal and then press up, ls
shows up)~/.zshrc
that deals with history:
[131013230010] |I can offer a fix for that last one: make sure the env variable HISTCONTROL does not specify "ignorespace" (or "ignoreboth").
[131013230020] |But I feel your pain with multiple concurrent sessions.
[131013230030] |It simply isn't handled well in bash.
[131013250010] |john
, the system comes back to full strength after a few seconds.
[131013250070] |This is an extreme example but I have similar issues with slightly less write-intensive activities like copying big files from fast sources or transcoding.
[131013250080] |My main OS disk is a quite fast SSD (OCZ Agility 60GB) with EXT4.
[131013250090] |If I write john
's output to a mechanical disk with EXT4, I don't experience the same slow-downs though the rate is a lot slower (SSD does ~42,000 words per second, mechanical does 8,000 w/s).
[131013250100] |The throughput may be relevant.
[131013250110] |The mechanical disk also has nothing to do with the system.
[131013250120] |It's just data.
[131013250130] |And I'm using kernel 2.6.35-2 but I've noticed this issue since I got this SSD when I was probably using .31 or something from around that time.
[131013250140] |So what's causing the slowdown?
[131013250150] |EXT4 issue?
[131013250160] |Kernel issue?
[131013250170] |SSD issue?
[131013250180] |All of the above?
[131013250190] |Something else?
[131013250200] |If you think I need to run an additional test, just drop a comment telling me what to do and I'll append the result to the question.
[131013260010] |This has been a known issue for awhile.
[131013260020] |Using an SSD-tuned FS like Btrfs might help, but it might not.
[131013260030] |Ultimately, it is a bug in the IO scheduler/memory management systems.
[131013260040] |Recently, there have been some patches that aim to address this issue.
[131013260050] |See Fixed: The Linux Desktop Responsiveness Problem?
[131013260060] |These patches may eventually make their way into the mainline kernel, but for now, you will probably have to compile your own kernel if you want to fix this issue.
[131013270010] |There are a few things you can check on to try to improve SSD performance under Linux.
[131013270020] |1) Set the mount point to 'noatime'.
[131013270030] |Extra activity updating access times are generally wasted on most use cases.
[131013270040] |Especially in the case of continually pumping single lines into a file, you are forcing multiple updates to the filesystem for every access.
[131013270050] |2) Check the elevator.
[131013270060] |The default elevator for most distros are set up for random access spinning platters.
[131013270070] |SSD's don't need the extra logic, so setting the elevator to noop can improve performance by letting the hardware manage the writes.
[131013270080] |3) Write-through v write-back caching.
[131013270090] |This is a bit more esoteric, but you can check the caching method used with hdparm for the device.
[131013270100] |Write-back caching can have a positive impact on SSD performance compared to write-through.
[131013280010] |0
to paste to line 1
.
[131013330030] |This will also work with ranges:
[131013330040] |will copy lines m
through n
to line k+1
.
[131013330050] |In addition it doesn't matter where you are in the buffer.
[131013330060] |The move
command, m
, works similarly.
[131013340010] |/etc/rc.d
, typically one script per daemon, or one script per subsystem.
[131013370030] |For example, Slackware starts the Apache web server with a script /etc/rc.d/rc.httpd
, called at the appropriate time during system startup with an argument of "start".
[131013370040] |Arch linux has differently-named scripts, but the same sort of thing goes on.
[131013370050] |To keep some process from starting during system boot, on Slackware, you just make the appropriate script in /etc/rc.d not executable.
[131013370060] |To keep Apache from starting at the next boot:
[131013370070] |To stop an Apache that got started at boot: /etc/rc.d/rc.httpd stop
You'll need to be root.
[131013370080] |Arch is a bit more complex.
[131013370090] |The file /etc/rc.conf, a shell script, has an array DAEMONS.
[131013370100] |To keep Apache from starting at boot, you'd change this line in /etc/rc.conf:
[131013370110] |To this line:
[131013370120] |To stop an already executing apache, you'd execute /etc/rc.d/httpd stop
as root.
[131013380010] |If you are dealing with a modern Ubuntu system and a few other distros you may have to deal with a combination of traditional init scripts and upstart scripts.
[131013380020] |Managing init scripts is covered by other answers.
[131013380030] |The following is one way to stop an upstart service from starting on boot:
[131013380040] |The problem with this method is that it does not allow you to start the service using:
[131013380050] |An alternative to this is to open the servicename.conf
file in your favorite editor and comment out any lines that start with:
[131013380060] |That is, change this to
[131013380070] |where the "..." is whatever was after "start on" previously.
[131013380080] |This way, when you want to re-enable it, you don't have to remember what the "start on" parameters were.
[131013380090] |Finally, if you have a new version of upstart you can simply add the word "manual" to the end of the configuration file.
[131013380100] |You can do this directly from the shell:
[131013380110] |This will cause upstart to ignore any "start on" phrases earlier in the file.
[131013390010] |printf
tool that simulates the C function; normally it's at /usr/bin/printf
, but a lot of shells implement built-ins for it as well.
[131013480020] |You can use %02x
to get the hex representation of a character, but you need to make sure you pass a string that includes the character in single-quotes (Edit: It turns out just a single-quote at the beginning is sufficient):
[131013480030] |You can make a shell function for convenience:
[131013490010] |Try od:
[131013490020] |$ echo -n "-_." | od -A n -t x1
[131013490030] |2d 5f 2e
[131013490040] |-A n
means do not print offsets and -t x1
means that the type of the input is hexadecimal integers of 1 byte.
[131013500010] |ssh -D4545 domain.com
to open a socks proxy tunnel at port 4545 to the desired machine from your computer.
[131013520020] |you can then set up that proxy in your application (say Firefox) and use a plugin to quickly engage and disengage the proxy settings (something like TorButton).
[131013520030] |There is one drawback though, when your target host has more than one network device, you cannot control which one will your data take to leave the machine you're tunneling to.
[131013520040] |This can be circumvented by installing a normal proxy server on that machine, routing the traffic from, say, localhost:3128
to the desired network interface, and then doing a ssh -L4545:localhost:3128
and pointing all applications to 4545 that ought to use the proxy.
[131013520050] |This gives you greater control on the proxy side, as the integrated proxy of SSH is not really configurable.
[131013530010] |chmod -R 755
.
[131013530030] |Now every file is executable, which I don't want.
[131013530040] |I am thinking that I should look at the first two bytes of each file for the #!
, but will this cover everything?
[131013530050] |Should I instead use file
to look at everything and base my decision on that?
[131013530060] |Or, more likely, is there an even better way to do this?
[131013530070] |What is the preferred way to recursively go through a directory and set -x on files that are not 'supposed to be' executable?
[131013540010] |Unfortunately, you can't rollback.
[131013540020] |If you have a backup, you're in luck.
[131013540030] |You can create a script that will compare permissions from your backup, and reproduce them on your existing folder.
[131013550010] |Well, without a shebang line, the file will be executed as a shell script, nominally with /bin/sh
.
[131013550020] |You're idea is a good start and on the assumption that the directory in question doesn't contain mission-critical files there probably isn't much risk to executing some grep
and chmod
combo.
[131013550030] |You may encounter false positives, i.e., files with a shebang line that are not meant to have their executable bit set but without knowing more information on the purpose of what's in the directory, only you can decide whether that poses a significant existential threat to your system and/or data.
[131013560010] |I believe you will want something like
[131013560020] |find dir -type f -exec chmod ugo-x '{}' +
[131013560030] |This looks for all regular files, recursively in dir, (it excludes directories, and devices) and removes the executable bit.
[131013560040] |I would start here, and then work my way towards making files that are supposed to be executable, executable.
[131013560050] |The following should work exactly as you asked for ( it will find all regular files, grep them for #! and then remove the x bits if not found )
[131013560060] |possibly a better version of the above (less pipes)
[131013570010] |There's no magic bullet here.
[131013570020] |The permissions carry information which is not always redundant.
[131013570030] |If you'd done this in a system directory, your system would be in a very bad state, because you'd have to worry about setuid and setgid bits, and about files that are not supposed to be world-readable, and about files that are supposed to be group- or world-writable.
[131013570040] |In a per-user directory, you have to worry about files that aren't supposed to be world-readable.
[131013570050] |No one can help you there.
[131013570060] |As for executability, a good rule of thumb would be to make everything that doesn't look like it could be executed, be nonexecutable.
[131013570070] |The kernel can execute scripts whose first two bytes are #!
, ELF binaries whose first four bytes are \x7fELF
where \x7f
is the byte with the value 12, and a few rarer file types (a.out, anything registered with binfmt_misc
).
[131013570080] |Hence the following command should restore your permissions to a reasonable state (assumes bash 4 or zsh, otherwise use find
to traverse the directory tree; warning, typed directly into the browser):
[131013570090] |Note that there is a simple way to back up and restore permissions of a directory tree, on Linux and possibly other unices with ACL support:
[131013580010] |fdisk -l
to see all the partitions and find how mine is listed.
[131013590030] |It will be something like /dev/sda1
.
[131013590040] |As a note the drive I installed has been used before so it had existing partitions.
[131013590050] |With an un-partitioned drive I have a feeling this will not work.fdisk /dev/sda
to run fdisk.
[131013590070] |You drop the number off the end to get the physical drive name.
[131013590080] |Type: p
to list the partitions on the drive again.
[131013590090] |This is mainly a sanity check to make sure you are working on the correct drive.
[131013590100] |If you have partitions on the drive you need to delete then type d
and follow the prompts to delete them.
[131013590110] |Type: n
to create a new partition.
[131013590120] |It will prompt you to create an extended or primary partition.
[131013590130] |I did primary so I did p
.
[131013590140] |It will then prompt for partition number.
[131013590150] |I did 1
.
[131013590160] |It will then prompt for first cylinder number.
[131013590170] |I just hit enter for the default of 1
.
[131013590180] |It will then prompt for the last cylinder number.
[131013590190] |I just did the default based on my disk size and hit enter.
[131013590200] |You can the type p again to verify the new partition is entered correctly.
[131013590210] |Type t
to enter the hex code for the type of partition you want.
[131013590220] |I did 83
for ext2.
[131013590230] |Type w
to write the partition table.mkfs -t ext2 /dev/sda1
to actually format the partition.fsck -f -y /dev/sda
to check the drive, and set it up to be mounted upon each reboot.mplayer
has the switch -heartbeat-cmd
to run a command every 30 seconds, but as the man page says:
[131013620020] |This can be "misused" to disable screensavers that do not support the proper X API
[131013620030] |The actual switch meant to disable screensavers is -stop-xscreensaver
; you should probably try that first
[131013630010] |ark
the KDE archiving tool can be run without a GUI.
[131013670020] |From the ark
manpage
[131013670030] |Will extract archive.tar.bz2 into the current directory without showing any GUI.
[131013670040] |Arks support of various archive formats depends on which apps you have installed (e.g. for rar it depends on unrar ), but I don't know of any formats it can't handle.
[131013680010] |You can use p7zip.
[131013680020] |It automatically identifies the archive type and decompress it.
[131013680030] |p7zip is the command line version of 7-Zip for Unix/Linux, made by an independent developer.
[131013680040] |7z e
[131013690010] |In Debian/Ubuntu there is the unp
package, which is a Perl script that acts as a frontend for many archiving utilities.
[131013700010] |From another question: atool, which also handles various archive types and is more powerful than unp
because it also handles listing of contents, finding differences between archives etc.
[131013710010] |I found this little snippet a while ago and have been using it since.
[131013710020] |I just have it in my .bashrc file
[131013720010] |top
command that updates the results after some fixed intervals of time.
[131013730010] |It would help if you were a lot more specific about what you are trying to do.
[131013730020] |Here is an extremely simplistic example:
[131013740010] |Most of that data is generally exposed in the /proc virtual file-system primitives.
[131013740020] |Each process has an entry in /proc in a directory called the PID.
[131013740030] |So /proc/5437 would have the primitives for the 5437 process.
[131013740040] |Reading the primitives there and parsing appropriately would yet you close to what top does.
[131013740050] |Top actually works by calling specific function calls that extract this information directly from the kernel instead of pulling it from files.
[131013740060] |To do the same from bash you'd have to either pull it from the /proc virtual file system, or extract it out of other calls such as to ps
.
[131013740070] |As for real-time, that isn't quite doable at the level of detail top provides.
[131013740080] |You can slice time fine enough that it appears to be real-time, but you will still be getting time-slices.
[131013750010] |Top uses Curses and reads the /proc file system
[131013760010] |Erm, in case you're looking at top
output for a longer time, and not just to check if a program is doing fine, I suggest using htop.
[131013760020] |It give's you a lot of real time information and is easier to control and manage.
[131013760030] |You can change the layout of the output, such as bar graphs and columns.
[131013770010] |you can use the watch(1) command to run your script at regular intervals:
[131013770020] |This will run myscript.sh
every 1 second clearing the screen between each run and with a timestamp in the corner.
[131013770030] |You can use the -d
option and it will even highlight differences in the output per run.
[131013780010] |s/preceding-text$/preceding-text nomodeset$/g
[131013790020] |The $ assumes that it's right at the end of the line.
[131013790030] |The preceding text would have to be unique to the lines you need to hit.
[131013800010] |Look for the kopt=
, defoptions=
and altoptions=
lines beginning with ##
in your menu.lst
file.
[131013800020] |These specify options to be used when the menu entries are first created by installing a new kernel.
[131013800030] |No need to edit the file afterwards.
[131013800040] |You can also update all your existing entries by running update-grub
.
[131013800050] |For grub2, the file to edit is /etc/default/grub
, and the same command to update.
[131013800060] |However, the parameters to change are GRUB_CMDLINE_LINUX_DEFAULT
and GRUB_CMDLINE_LINUX
.
[131013800070] |For a one-off change, you can make temporary edits to the options directly in grub, by entering the "edit commandline" mode.
[131013810010] |Read the release notes
[131013810020] |Basically, you can use your favorite text editor to edit /boot/grub/menu.lst as root.
[131013810030] |Add nomodeset to the kernel boot line.
[131013810040] |Or set the NO_KMS_IN_INITRD sysconfig variable to yes via YAST.
[131013820010] |ls
, ps
, cat
etc?
[131013820030] |Why is it shell specific?
[131013820040] |Any good reasons?
[131013830010] |According to the dash
man page, there are two classes of builtins.
[131013830020] |Some commands have to be built-in because they cannot work if they are external. cd
is one such since if it were external, it could only change its own directory, it couldn't affect the current working directory of the shell.
[131013830030] |The other class of commands are built into the shell purely for efficiency.
[131013830040] |The dash
man page mentions printf
, echo
, and test
as examples.
[131013830050] |In the beginning, the builtins in the second class were separate executables.
[131013830060] |These separate executables are still available on every Unixy system I've used, even though they're also built into every shell you're likely to use.
[131013830070] |By checking old manuals, I've been able to narrow the window where echo
got built into the shell to some time after Unix System III was released (1982), where echo
is not built-into the shell, but no later than Unix System V Release 3.1 (1987), where it is.
[131013830080] |I don't have manpages for any of the major candidate systems that appeared between these two, so echo
could have been made a builtin before SVR3.
[131013830090] |If so, likely candidates are 4BSD, SVR1, or SVR2. I include BSD in the list because System V Release 1 brought a lot of BSD innovations back home to AT&T, including vi
and curses
, so that could explain echo
's appearance as a builtin in the SVR3 manuals I have here even if it were a BSD feature originally.
[131013840010] |Although most shells include a built-in echo
nowadays, the GNU CoreUtils also include a standalone implementation of it:
[131013840020] |It sounds like you don't have GNU Coreutils installed (most linux-based desktop &server OS have it installed by default, but embeded linux or other UNIX might use alternative collections of shell utilities instead).
[131013840030] |BTW: if you look at Busybox, you'll see that ls
, ps
and cat
are also built-in commands there (or at least can be; it's used for embeded systems and everything not needed can be left out).
[131013850010] |According to the Bash Reference Manual, it's about convenience.
[131013850020] |Shells also provide a small set of built-in commands (builtins) implementing functionality impossible or inconvenient to obtain via separate utilities.
[131013850030] |For example, cd, break, continue, and exec) cannot be implemented outside of the shell because they directly manipulate the shell itself.
[131013850040] |The history, getopts, kill, or pwd builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands.
[131013850050] |All of the shell builtins are described in subsequent sections.
[131013850060] |The Advanced Bash Scripting Guide has a more detailed explanation:
[131013850070] |"A builtin is a command contained within the Bash tool set, literally built in.
[131013850080] |This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off 1 a separate process -- or because a particular builtin needs direct access to the shell internals."
[131013850090] |Also note that echo
does exist as a standalone utility on some systems.
[131013850100] |Here's what I have on my Darwin system (MacOSX 10.5.8 - Leopard)
[131013850110] |echo
is also available as a builtin, but apparently my scripts use /bin/echo on my Mac, and use a Bash builtin on most of my Linux &FreeBSD systems.
[131013850120] |But that doesn't seem to matter, because the scripts still work fine everywhere.
[131013860010] |There is a third reason for some commands to be built-in: They can be used when running external commands is impossible.
[131013860020] |Sometimes a system becomes so broken that the ls
command does not work.
[131013860030] |In some cases, an echo *
will still work.
[131013860040] |Another (more important!) example is kill
: If a system runs out of free PIDs, it is not possible to run /bin/kill
(because it needs a PID :-), but the built-in kill
will work.
[131013860050] |Btw., which
is an external command (at least it is not internal in bash), so it cannot list internal commands.
[131013860060] |For instance:
[131013870010] |termcap
settings for screen.
[131013880020] |Maybe you can try starting screen with the -a
command line option.
[131013890010] |Some terminals, such as xterm, support what is known as an “alternate screen”: there are separate screens for full-screen programs and for scrolling programs.
[131013890020] |In xterm, you can switch between the two screens with the “show alternate screen” command at the bottom of the Ctrl+mouse 2 menu.
[131013890030] |This behavior is disabled by default in screen but can be enabled with the altscreen
option: add altscreen on
to your ~/.screenrc
.
[131013900010] |Gilles is correct:
[131013900020] |altscreen on
[131013900030] |in your .screenrc or /etc/screenrc (the latter if you want this behavior for all users) will do what you describe.
[131013900040] |This is also the case when screen is used from a 'real' terminal.
[131013900050] |Here is the terse description in the docs: gnu.org
[131013910010] |foobar
's definition, find all places where the variable foo
is referenced, find all files including bar.h
, change all occurrences of bar
into baz
, etc.
[131014060030] |Also, you mentioned Vim in your post... here is a tutorial on using Vim &Cscope together.
[131014070010] |$
came up after I logged in as a new user.
[131014070040] |This was unexpected because my main user's prompt starts with username@computername:~$
.
[131014070050] |So, how do I switch from this other shell to bash?
[131014080010] |you type in bash
.
[131014080020] |If you want this to be a permanent change the default shell to /bin/bash
by editing /etc/passwd
.
[131014080030] |here's some snipets from my /etc/passwd
the very last field contains the shell, Modifying the field after the last :
to a valid or invalid shell will work. /bin/false
and /sbin/nologin
both mean the user doesn't have a real login shell, although if pam is not set up right this doesn't mean they can't login (I reported a bug on this in Arch Linux, because you can login graphically without having a login shell). /bin/bash
and /bin/zsh
are both valid shells, see /etc/shells
for a list of valid shells on your systems.
[131014080040] |Here's my /etc/shells
if you're interested.
[131014080050] |Yes you can use chsh
or usermod
to do the same things, please remember these are just structured text files, and TIMTOWTDI.
[131014090010] |Assuming the unknown shell supports running an absolute command, you could try: /bin/bash
[131014090020] |To change the default shell, I would use chsh(1)
.
[131014090030] |Sample usage: chsh -s /bin/bash your_user
[131014100010] |If chsh or manually editing the config won't work, but a ~/.profile script is executed at login, add this line:
[131014110010] |cut
exists for exactly this purpose.
[131014130020] |The -d
flag specifies the delimiter, and -f
specifies which fields to output:
[131014130030] |The argument to -f
can be something like 1,3
to show the first and third fields, or 1-3
to show the first three; there are also -b
and -c
flags to read bytes and characters instead of fields.
[131014130040] |If you need something more flexible, generally awk
will do the trick (see Matthew's answer)
[131014140010] |Here's a Perl one-liner:
[131014150010] |xargs
or something similar:
[131014150050] |When I try this, only the first command runs.
[131014150060] |How can I achieve what I want to do?
[131014160010] |And the commands are executes in parallel, if this it is, what you want to do.
[131014160020] |Else replace the &chars.
[131014170010] |For shells such as Bash, Korn and Z that have process substitution, you can do this:
[131014180010] |I wouldn't vote for this myself.
[131014180020] |It's silly and dangerous, but just in the interest of listing the ways to do this, there's:
[131014180030] |for cmd in "commandA" "commandB" "perl -ne '...'" ; do eval $cmd file ; done
[131014190010] |You can use xargs to construct a command line e.g.:
[131014190020] |Just pipe the above into bash to run it:
[131014190030] |Extending the example to all the *.c files in the current directory (escaping the ls here to prevent any shell alias substitution):
[131014200010] |diff
between the two files within Vim?
[131014200040] |I am aware of the :next
and :prev
commands, but this is not what I'm after.
[131014200050] |It would really be nice to view the two files in tandem.
[131014210010] |Open the side by side view:
[131014210020] |Change between them:
[131014210030] |Checkout the vimdiff command, part of the vim package, if you want a diff-like view..
[131014220010] |fdisk -l
as root to see how your disk has been partitioned.
[131014240010] |open up a terminal and list your drives first:
[131014240020] |output similar to this:
[131014240030] |From this you can see Disk /dev/sdb, and /dev/sda as disks.
[131014240040] |To view partition table of one do:
[131014240050] |Press "p" to list partitions or m for help.
[131014240060] |From here you can modify partition tables, and when you are all finished press "w" to write changes to disc.
[131014240070] |Next if you create a new partition, lets say ext3 you will need to use something like mkfs or a GUI based tool to create a ext3 partition there.
[131014250010] |There is no default partition format for Linux.
[131014250020] |It can handle many of popular and less popular formats.
[131014250030] |The type is determined by the tool you are using. fdisk
can handle standard MS-DOS partition tables while parted
can handle GUID partition tables as well.
[131014250040] |You can create other tools for any format you like.
[131014250050] |Most distributions will create MS-DOS partitions on standard PC and possibly use GUID tables on Macs for simple reason - Windows cannot boot from GUID partition table with BIOS (which is on standard PC) - only EFI (which is on Macs).
[131014250060] |As for second part - fdisk -l
presented will print standard partitions (thosed used on MS DOS). parted -l
will show all "partitions" - including for example LVM logical volumes.
[131014250070] |EDIT: If you want to bump partition table (binary) use dd if=/dev/your_disk count=1
.
[131014260010] |If you install Linux on a PC, the installation program will create one or more partitions in a format that is compatible with DOS, OS/2 and Windows, because that's the de facto standard for partitions on a PC.
[131014260020] |If you install Linux on some other kind of hardware, the installation program may use a different partitioning scheme.
[131014260030] |Linux supports a lot of different schemes (you can see them all in the kernel configuration — search CONFIG_.*_PARTITION
in /boot/config-*
).
[131014260040] |Even on a PC, you might see other partition types for a variety of reasons: because you went out of your way to create them, because you inserted a disk from some other architecture, because you have another operating system that uses different partition types (e.g. *BSD, Solaris).
[131014270010] |patch unexpectedly ends in middle of line
mean, and is it a problem?
[131014320060] |Is it referring to hunk 16 or 17?
[131014320070] |What can I look for in the patch file to figure out what's causing this?
[131014330010] |The message refers to Hunk 16.
[131014330020] |This git hub discussion is probably related to your issue.
[131014340010] |~/.zsh.d/functions.sh
[131014340040] |and relevenat sections from my ~/.zshrc
[131014340050] |This works right, except that it doesn't display -- INSERT --
when the shell is first started, after that it works as expected.
[131014340060] |other improvement suggestions welcome
[131014340070] |Update I decided to work around the issue, though I still don't know why it works.
[131014340080] |For now I've set psvar[1]
to -- INSERT --
out of the box, since I know it will be insert on start.
[131014340090] |This doesn't feel like a proper resolution though.
[131014350010] |In my hacker it appears I fixed it by setting
[131014350020] |before doing anything else with my vimode...
[131014350030] |I"m not sure I'm 100% satisfied with my solution, but it functions.
[131014360010] |%#
in your PS1
(or whatever PROMPT
variable) which basically means display %
if user or display #
if root.
[131014360030] |I'm wondering if there is any way to affect this so that the %
or #
changes colors depending on whether it's a user or root (a red for root, a blue for user ) the obvious way is just to change the PS1
in my root's ~/.zshrc
but considering this is already a special symbol I'm wondering if there isn't perhaps a way I can use the same PS1
for both... something specific to %#
like it is for zsh ( I'm sure there are other hacks I could do too like an if then statement ).
[131014370010] |%(!.%{\e[1;31m%}%m%{\e[0m%}.%{\e[0;33m%}%m%{\e[0m%})
[131014370020] |That should work to change the hostname (%m
) a different color (red) if you are root.
[131014370030] |I don't have a zsh shell to test it on but it looks correct.
[131014370040] |Here's why:
[131014370050] |%(x.true.false)
:: Based on the evaluation of first term of the ternary, execute the correct statement. '!' is true if the shell is privileged.
[131014370060] |In fact %#
is a shortcut for %(!.#.%)
.
[131014370070] |%{\e[1;31m%} %m %{\e[0m%}
:: the %{\e[X;Ym%}
is the color escape sequence with X as formatting (bold, underline, etc) and Y as the color code.
[131014370080] |Note you need to open and close the sequence around the term you are looking to change the color otherwise everything after that point will be whatever color.
[131014370090] |I've added spaces here around the prompt term %m
for clarity.
[131014370100] |http://www.nparikh.org/unix/prompt.php has more options and details around the color tables and other available options for zsh.
[131014380010] |%(#
tests whether the shell is running as root.
[131014380020] |Changing this to %(!
tests whether the shell is running with elevated privileges (which covers things like newgrp
, but not logging in as root).
[131014390010] |lsof
cannot find anything that have device file opened or anything that keeps any file opened.
[131014410060] |It is some regression but I don't see any update that might have caused it.
[131014410070] |Drive is mount/unmount by usdisk.
[131014410080] |EDIT: To answer:
[131014410090] |Ctrl-c
)
[131014420080] |If this stops your device from frequently spinning, see my notes below about making the udev rule changes.
[131014420090] |If disabling hald and udisks polling makes no difference, then you can re-enable hald control of the device with this:
[131014420100] |Disabling polling of your DVD device may have the side effect of requiring you to mount optical media manually.
[131014420110] |Your drive may continue to provide notification to udev that it should take some action upon media insertion.
[131014420120] |Making udisks ignore your optical device is a simple rule.
[131014420130] |I put mine in /etc/udev/rules.d/99-device-polling.rules:
[131014420140] |Get your vendor and model strings from the output of udisks --show-info /dev/dvd
.
[131014420150] |Make the changes active by running udevadm trigger
, then re-examine udisks --show-info /dev/dvd
and note the line "detection by polling:" - it should be 0.