Arcege
  • Member for 11 years
  • Last seen more than a month ago
How to clean up output of linux 'script' command
Accepted answer
37 votes

If you want to view the file, then you can send the output through col -bp; this interprets the control characters. Then you can pipe through less, if you like. col -bp typescript | less -R On some ...

View answer
How to display the line number in Vim?
17 votes

Run :set number to add a left margin with the line numbers. Use :help 'nu to see help on the topic, including changing the margin size. For some permanence, place the command, without the leading ...

View answer
GNU screen - Unable to reattach to screen after lost connection
14 votes

If you are trying to connect the 'Attached' screen, then run screen -xr irssi. The uppercase '-X' sends a command to one of the screen sessions, the lowercase '-x' option allows you to reconnect to an ...

View answer
How do I show the header of a file in Unix?
12 votes

I generally use od -bc {filename} | head to look at the header of a binary file. view works too, but I find that it is generally better to see the output directly on the terminal.

View answer
How can I force Chrome to refresh a page, ignoring cached Flash files?
9 votes

Try Ctrl-Shift-R (instead of Ctrl-r) to tell the browser to reload the page ignoring the cache. You can also hold down the Shift key and click on the refresh button.

View answer
How can I find out my WiFi adapter's MAC address on Ubuntu Linux?
8 votes

Combining the answer from @user562374 with a little scripting: ip addr show $(awk 'NR==3{print $1}' /proc/net/wireless | tr -d :) | awk '/ether/{print $2}' The wireless interface is shown in /proc/...

View answer
How can I yank multiple lines into a register?
7 votes

You prefix the command with a number to get how many lines to operate on. You could also use a 'text-object' (like ']' for block, and ')' for paragraph) - this would work on multiple lines ...

View answer
Can I re-attach SSH key forwarding through a disconnected Screen session?
Accepted answer
6 votes

My solution is a bit more robust. Put this in your .bash_profile on the remote side. if [ -z "${STY}" -a -t 0 ]; then reattach () { if [ -n "${SSH_AUTH_SOCK}" ]; then ln -snf ...

View answer
How can I disable any users (except root) from executing `wall`?
Accepted answer
6 votes

If you want to deny access to for all users, then you might want to remove the setgid bit on /usr/bin/wall: $ ls -l /usr/bin/wall -rwxr-sr-x 1 root tty 13884 2011-08-09 12:15 /usr/bin/wall $ sudo ...

View answer
How to list all users that have terminal sessions, including screen sessions?
Accepted answer
5 votes

Try: $ ps axno user,tty | awk '$1 >= 1000 && $1 < 65530 && $2 != "?"' | sort -u This should tell you all UIDs with processes with a session terminal (like a window in screen). ...

View answer
What is the linux equivalent for dos command: dir /s /ah
5 votes

I usually use ls -lAR which recurses through a directory tree, showing file attributes and any 'hidden' files (commonly called 'dot files' because they start with a dot ('.'). You could also replace ...

View answer
How should I automatically change my .zshrc for different OS'?
4 votes

I used to use this mechanism: envfile="$HOME/.bash/os.`uname`.sh" if [ -r $envfile ]; then . $envfile fi envfile="$HOME/.bash/host.`uname -n`.sh" if [ -r $envfile ]; then . $envfile fi Then ...

View answer
Copied directory appears to become larger at destination
4 votes

My first through is that it would largely depend on the type of files in the source directory. I would think that the likely culprit are sparse files. A sparse file is one where where stat.st_size !=...

View answer
Search for files with more than one term (grep, awk?)
3 votes

You can use either the -e or -f options to search for multiple expressions (from man grep): -e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. This can be used to specify ...

View answer
Reopen screen session after connecting to server
3 votes

I use the following in my .bash_profile: # if not running screen, attached to a terminal and is myusername (not run through sudo) if [ -z "${STY}" -a -t 0 -a X${USER} = Xmyusername ]; then # ...

View answer
How to find a content of any file in UNIX base system
Accepted answer
2 votes

You may likely have to look in several locations. The top directory of the web servers installation directory (could be /var/www/htdocs); if you are using Apache HTTPD, then you can look at the ...

View answer
GNU Screen prepending dollar signs to window titles
2 votes

Look under the windows command in the documentation and you'll see: The current window is marked with a `*'; the previous window is marked with a `-'; all the windows that are logged in are marked ...

View answer
using emacs shell with gnu screen?
Accepted answer
2 votes

I'd say 'good luck'. From what I remember, and what I just tried, emacs does not handle full terminal support under the shell command. For example, in an emacs shell, I try: $ less /etc/hosts ...

View answer
Ubuntu shortcut shell script launcher for multiple items
Accepted answer
2 votes

It's not that hard. First you need to know what you want to start, let's say five gnome-terminal instances, and then set it up in your windowing system to have an icon to click on to start the ...

View answer
What's the best command to use to change a timestamp to readable date when 'tail -f'-ing a log file?
2 votes

I assume that you want the date to be changed inline, printing the rest of the line as well. Try replacing field 1 with the output of strftime(). $ echo "1234218770.7644 INFO etc' | awk '{$1=...

View answer
Cron ignoring an update to crontab
2 votes

Check the manpage on your system for crontab(5) (man 5 crontab), especially under the "EXAMPLE SYSTEM CRON FILE" section. Only the /etc/crontab file includes a username field. Non-system user ...

View answer
Using wildcards with tar
Accepted answer
2 votes

The likely problem is that you are not in the root directory (/), but your wildcards assume that you are. Remember that the shell expands wildcards on the command-line before envoking the program. ...

View answer
Besides ls, cd, mv, cp, chmod/chown, sudo and vi, what are the most useful command line utilities to master?
2 votes

sed - file manipulation, e.g. sed -e '/<foo>/,/<\/foo>/{;s/bar/widget/;}' xyzzy.xml awk - file manipulation, my favorite idiom is du -sk * | awk '{sum+=$1}END{print sum}' ...

View answer
Not getting gigbit from a gigabit link?
2 votes

The term 'theoretical maximum' is thrown around, but it does have a practical application with Ethernet technologies. On a CSMA/CD system like Ethernet, you can only send about half the bandwidth of ...

View answer
is there a way to save what's printed on the display with gnu screen?
2 votes

You will want to use the 'log' operation, usually bound to Ctrl-a H. This opens a new file called screenlog.N where N is the window number. If the file exists, then output is appended to the file. ...

View answer
How to keep a remote task running after running it in an SSH console?
2 votes

Try using nohup mongod &. This will prevent the program from receiving SIGHUP signals which are sent when the shell exits (after the connection is lost). This is a standard shell builtin in all ...

View answer
Is the zero exit status different to that of boolean logic when using the Linux shell?
1 votes

The better rationale is that there is really only one 'success', but there are multiple reasons for a 'failure': file not found, argument error, computational error, etc. This was a convention of the ...

View answer
Split vertical for GNU screen in cygwin
1 votes

There is a patch to add vsplit to gnu screen, and people have gotten it to run on cynwin (http://cygwin.com/ml/cygwin/2010-08/msg00135.html). You might be able to find a binary out there or you might ...

View answer
Use gnu-screen and X instead of desktop environment?
1 votes

There is no correlation between screen and a windowing environment ("window manager"). No matter what form of windowing manager you run, you can still run screen. The question then becomes what lose/...

View answer
How do you get screen to automatically connect to the current ssh-agent when re-attaching to an existing screen?
1 votes

I commonly keep long term (6+ months) sessions running at my workplace on different servers. So repeatedly reattaching and having a viable ssh forwarding agent has been problematic. This is what I ...

View answer