Tag Info

Hot answers tagged

20

You can run less +F filename in order to view file in tail -f fashion. You can press Shift+F while viewing file in less to switch to forwarding mode, and Ctrl+C to leave this mode.


16

Note: Due to legacy licensing reasons, most GNU/Linux distributions don’t include the original vi program as written by Bill Joy. Instead, the vi command is provided by running Vim in vi-compatibility mode. The following answer is based on running Vim with its vi-compatibility mode. Modifying a read-only file Vim warns the user if they modify the buffer of ...


8

Suppose you have a split RAR with parts numbered up to 12 (i.e., filename.r12 as your last file) and you want to be extra careful not to remove any other files. Assuming bash is your shell and you're using version 4 or higher (bash --version to check), you can create an explicit list of files easily with brace expansion: rm filename.rar filename.r{01..12} ...


6

Depending on the number of .r0* files you have you could replace the * with a ? this will remove files that have .r0 and 1 other character. So it will remove rabbid.ranger.robot.r01 but not rabbid.ranger.robot.r010 Generally I would use it as such: rm filename.r??


6

You can use find to list executable files: find /foo -type f -executable You can then use the -exec option to create the link. -exec command ; Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of `;' is encountered. ...


5

To delete all files ending in .jpg (case-insensitive) except for files with sample in the file name (case-insensitive: find . ! -iname '*sample*' -iname '*.jpg' -delete This recurses through all directories in the tree starting at the current directory. How it works: . This specifies that we start with the current directory. ! -iname '*sample*' ...


5

From less -help: F Forward forever; like "tail -f". so presumably less +F /var/log/messages


5

Please check the sshd configuration file if Public Key Authentication is enabled search in /etc/ssh/sshd_config for #PubkeyAuthentication yes If it is commented out remove the leading '#'. if it is set to 'no' change it to 'yes' As @Darius mentioned please also check the setting AuthorizedKeysFile It should be commented out for default behaviour. Then ...


4

You could try using ddrescue instead of dd. ddrescue has a switch to do only a limited number of retries. It can also use a logfile, so it records which blocks were bad. If you later feel like doing more retries, you can use the same logfile to run ddrescue again with different options (like more retries) and it will retrie only the necessary blocks. ...


4

The Slackware installation disc uses a generic Linux Live-CD setup which includes a multi-user system. Therefore you are required to log in. Username: root Password: live I would advise you, if you are not familiar with Linux, to try another distribution before using a 'hardcore' distro like Slackware. Fedora and Ubuntu are much more user friendly for ...


4

Loopback is special. It's the entire 127.0.0.0/8 space, and it never leaves the machine. That is the only exception to listening for only configured addresses, if it's on loopback it's special. I can't think of any security implications to that, since those addresses can never be on the physical network.


4

You can use the find command; from the working directory: find . -type f -name "filename.*" -exec rm {} \; This searches only for files that match, directories are excluded. It may be a good idea to first test the command with ls rather than rm to make sure it’s returning the results you desire. find . -type f -name "filename.*" -exec ls {} \;


4

Another possibility: for i in ~/foo/*; do [ -x "$i" ] && ln -s "$i" ~/bar; done -x tests if the file exists and is executable. See man test for more information. If you want to create working relative links you might need to think about how you provide your directory paths, or use the -r option to ln (which is a somewhat new GNU extension (≥ ...


4

The terminal expects to use a monospace font, but you have used a proportional font. So when the cursor moves right or left, it moves by a fixed amount each time, rather than proprtionally based on whatever character was on the screen. Thus your columns are not lined up and moving backward ends up in the wrong place. To fix the problem, change the terminal ...


3

It's simple enough to parse the output into the format you want: xxd -b /root/Desktop/image.png | cut -d: -f 2 | sed 's/ .*//; s/ //g' The cut will remove the line numbers and the sed will first remove the last column (s/ .*// will remove everything that comes after two consecutive spaces) and then removes all single spaces. You could also use awk: ...


3

The program Truecrypt is commonly used for this purpose and is cross-platform. There was a famous announcement about it being discontinued with a suggestion to use (windows-specific) ntfs encryption. I've not looked into the status lately, but use a version from before the hiatus. Meanwhile, a peer-review code review and audit was already underway, so it ...


3

In principle, it is possible to modify an ISO by inserting a big enough dummy file. mkisofs even allows (via the -sort option) to put that dummy file at the beginning. There are 2 problems remaining: this dummy file might not be readable without errors if your DVD is worn out. That does not really matter, since that's what the dummy file is for. some ...


3

Boot from Windows 7/8/8.1 DVD and start the repair console. To restore original Windows bootloader type the following command: > bootrec /fixmbr That is it! Optionally you can also rebuild bootsector if it is corrupted: > bootrec /fixboot After that, Windows will boot as usual, and you can remove Linux partition and extend Windows partition on ...


3

I'm not sure if this is homework so this might not fit your requirements but you don't actually need a whole script to do this. This can be done with a one-liner. cat /etc/passwd | cut -d ':' -f 7 | sort | uniq -c Here's what the output looks like 4 /bin/bash 6 /sbin/nologin 4 /usr/bin/csh 13 /usr/bin/ksh How this works is that uniq(1) "Filters ...


3

There are these options in grep: -A NUM will give you NUM lines after. -B NUM* will give you NUM lines before. -C NUM* both (NUM lines before and NUM lines after). Where NUM is an integer number. In your case grep -A 1 bbb file.txt will give you ccc.


3

Most if not all vi implementations prevent you to write the file if you use a regular save command like either ZZ, :w, :wq or :x, eg with vim: :w E45: 'readonly' option is set (add ! to override) On the other hand, if you tell vi to write the file despite its permissions, with using something like :x! or :wq!, the editor is temporarily relaxing the ...


3

Nicolai's answer is probably closest to what you asked for, but have you thought about using tmux? In my tmux sessions, I like to tail -f logs, then simply enter tmux's copy mode to search up and down exactly like searching in less, then exit copy mode to find my tail -f still going. Create a tmux session: tmux Tail the log file and the last 1000 lines ...


3

You can run them with no display manager, but you do need a running X session. The details will depend on your distribution but you should be able to get a minimal X session with a single terminal by running xinit I haven't done this in years but, last time I did, that would give something like this: Once there, you can run a GUI program normally, ...


3

The latter prompt that you have seen is the default on Red Hat-based systems, such as Red Hat Enterprise Linux, CentOS, and Fedora. The former is the default on Debian-based systems such as Debian itself and Ubuntu. The default Red Hat PS1 prompt is: export PS1="[\u@\h \W]\\$ " You can of course change the prompt to whatever you wish. I prefer the Red ...


3

Here is the basics for running an GUI app headless, with a way (vnc) to connect to it. Works on RHEL7 and Centos 7, with family. And ripped out of my own Docker-image that I use for Crashplan located at https://github.com/xeor/dockerfiles/tree/master/crashplan/ (see Dockerfile for setup, and init/setup for startup. # Needed environment variables export ...


3

There are two steps to accomplish this. Step 1) Make sure your users are using the bash shell. Look at the entry for each user in /etc/passwd and ensure it ends in /bin/bash. For example, if you see this: joeuser:x:1234:1234:Joe User:/home/joeuser:/bin/sh then change it to this: joeuser:x:1234:1234:Joe User:/home/joeuser:/bin/bash Using bash should ...


2

Try using the preinstalled command sha256sum. It's usually in /usr/bin/, but you can find its location using which: $ which sha256sum /usr/bin/sha256sum There is also a package hashalot for Precise which installs the sha256 command to /sbin (see here). You can install it using: $ sudo apt-get install hashalot


2

alias application=/path/to/start.sh Symlinking would work too. Whether either of this is "best" practice depends on what you want to do.


2

Found a solution: Created a new shell script like this: current_dir=`pwd` dir_name=`basename $current_dir` rsync -a . ~/backup/$dir_name and when executing this it will create a new directory at the destination and copy current folder contents.


2

I like your script but, if needed, you can do it directly by command line from the current directory rsync -a $(pwd) ~/backup/



Only top voted, non community-wiki answers of a minimum length are eligible