TL;DR : cd ~/public_html/var/session/ && ls -1 | wc -l && perl -e 'for(<*>){((stat)[9]<(unlink))}' && ls -1 | wc -l
with a close follower from rsync: rsync -a – delete /tmp/empty/ ~/public_html/var/session/
.
I had to delete ~1.700.000 files in a Magento ./var/session/ folder
Count the initial number of files:
cd ~/public_html/var/session/
ls | wc -l
So I started looking on other solutions on the wild web and I came to this Kinamo post: Efficiently delete a million files on Linux servers that had 4 variants:
Details on those variants:
Beside that post, I found another solution proposed on a Unix StackExchange thread: Faster way to delete large number of files [duplicate] which had answers on another one: Efficiently delete large directory containing thousands of files. The solution was a delete-in-5000-files-batches script:
#!/bin/bash # Path to folder with many files FOLDER="/path/to/folder/with/many/files" # Temporary file to store file names FILE_FILENAMES="/tmp/filenames" if [ -z "$FOLDER" ]; then echo "Prevented you from deleting everything! Correct your FOLDER variable!" exit 1 fi while true; do FILES=$(ls -f1 $FOLDER | wc -l) if [ "$FILES" -gt 10000 ]; then printf "[%s] %s files found. going on with removing\n" "$(date)" "$FILES" # Create new list of files ls -f1 $FOLDER | head -n 5002 | tail -n 5000 > "$FILE_FILENAMES" if [ -s $FILE_FILENAMES ]; then while read FILE; do rm "$FOLDER/$FILE" sleep 0.005 done < "$FILE_FILENAMES" fi else printf "[%s] script has finished, almost all files have been deleted" "$(date)" break fi sleep 5 done
Stats for my test:
Obviously, the rsync is the fastest solution for deleting a huge number of files!
PS. There was another solution on one of the stackexchange threads above, that claimed that a Perl one-liner would be even faster:
cd ~/public_html/var/session/ && ls -1 | wc -l && perl -e ‘for(<*>){((stat)[9]<(unlink))}' && ls -1 | wc -lI tested it and it was really faster…
I had a problem with viewing/editing a 370 Mb SQL file in Windows (7) on a machine with 4GB of RAM.
I searched some solutions:
Common candidates:
Results:
Testing conditions:
So, my winners are:
As you can see it’s a mix of old and new. It’s a brand new desktop but with traditional components. We’re excited about the new technology but it’s important everyone feels at home. So a Mint desktop looks and behaves like a Mint desktop and this one feels both like Gnome 3 and the traditional Linux Mint desktops that preceded it. You can launch applications from the top left, easily switch between applications and workspaces using the window list or keyboard shortcuts, keep an eye on your notifications at the top and access Gnome 3 features like “activities” from the top-left corner.
Alright, far too often (especially in the IRC channels) there is a time where even the most beginner of users are faced with the terminal. It has many names: terminal, shell, console, “command prompt” even as a carryover from those familiar with Windows. Many people are frightened by it for some reason or another, so this tutorial will attempt to provide you the most basic of commands to enable navigation and basic system actions from the comfort of your keyboard.
Let’s get started shall we? Since everyone’s Mint version can be different, I’m not going to detail how to actually open the terminal. I’ll assume you can find it in the menu or by right-clicking in the desktop.
cd -> Used to navigate the directories. You can move to any location by path.
ls -> Used to list folder contents. You can view many kinds of file and folder attributes.
cp -> Copy files
mv -> Move files
rm -> Remove files
nano -> full command line text editor
mkdir -> Create directories
ps -> List processes
kill / killall / xkill -> Kill offending processes.
Pipes -> The most useful thing you will learn in *NIX. Redirecting output of a program to anothers input.
> and >> redirectors –> Send output to a file instead of the terminal.
tee -> Send output to both a file and the terminal
So you want to execute files or programs from the terminal? Make sure it’s marked executable. If not, see Quick Tip #4 below.
gconftool-2 – type string – set /apps/metacity/general/button_layout "menu:minimize,maximize,close"
CTRL-z
jobs
(returns a list of ids of the stopped processes and their description: [1]+ Stopped mc)
fg 1
(where 1 is the id of the desired process to resurrect from the above list)
$ sudo lshw
$ sudo lshw -C disk
$ sudo lshw -html > your-file-name.html
sudo apt-get install lm-sensors sensors-applet
#(ksensors for Kubuntu)
sudo sensors-detect
$ uname -m
x86_64 indicates a running 64-bit kernel. If you use see i386, i486, i586 or i686, you're running a 32-bit kernel. Note: x86_64 is synonymous with amd64.
cat /etc/debian_version
cat /etc/issue
lsb-release -a
(saucat /etc/lsb-release
)
update-alternatives – config x-www-browser
orupdate-alternatives – config www-browser
sudo find / -type l -print | xargs ls -lh
GUI:
FileLight, Disk Space Analyzer or gdmap
(Gnome)
KDiskFree or KDirStat
(KDE) CLI:
$ dd if=/dev/dvd of=dvd.iso # for dvd
$ dd if=/dev/cdrom of=cd.iso # for cdrom
$ dd if=/dev/scd0 of=cd.iso # if cdrom is scsi
These commands are useful for data CD/DVD images. For Audio CD’s there’s another (longer) story. (A simpler way would be to use specialized apps like: K3b, Acetoneiso, Brasero)
$ mkisofs -v -o /tmp/user-folder.iso -R /home/user/user-folder
$ cdrecord -scanbus
$ cdrecord -v -dao dev=1,0,0 speed=8 file.iso
-speed=XX
: Specify writing speed, -v
: Verbose output, -dev
: The virtual SCSI ID of the writing device [discovered with the earlier command]) sudo mount /dev/sdb1 /media/USB -t vfat
(sau ntfs / ext2/3/4) - montare partitie
sudo umount /dev/sdb1
- demontare partitie
sudo mkfs -t vfat /dev/sdb1
- formatare partitie
sudo eject /dev/sdb1
Subiectul este destul de bine detaliat aici. Pe scurt:
tar xzvf tarballname.tar.gz
tar xjvf tarballname.tar.bz2
cd tarballname
./configure
make
[all]
sudo checkinstall
[care inlocuieste:sudo make install
]
sudo dpkg -i file.deb
sudo alien -k file.rpm
(aftersudo apt-get install alien
, if not already installed)
sudo dpkg -i file.deb
echo -n "aaaaaa" | md5sum
md5sum file
for f in * ; do echo $f ; done
which just displays all files in this case.
This is easy, what I usually need and often forget how to do it is to execute some action exact number of times. Something like simple for loop in C or Java. And there is an exact match for such loop in Bash too:
for (( i=1 ; i
I found another similar solution on the Internet today at spiralbound.net:
for i in $(seq 1 100); do echo $i ; done
rename ‘y/A-Z/a-z/’ *
echo "" > file
cp /dev/null file
dd if=/dev/zero of=output.file bs=1 count=1
cat /dev/null > your_file
>filename
touch /tmp/newfilename
mktemp
which outputs something like: /tmp/tmp.yTfJX35144
script example:
#!/bin/bash OUT=$(mktemp /tmp/output.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; } echo "Today is $(date)" >> $OUT
Go toUbuntu Software Center
. ClickEdit
. ClickSoftware Sources
. Switch to theOther Software
tab and checkCanonical Partners
. This may take some time.
Command
prompt, type the following sequence of commands:
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin
sudo update-alternatives – config java
open
~/.gstreamer-0.10
remove or rename theregistry.x86_64.bin
Open your music player.
It’ll regenerate the registry file and correctly use the aac plugin.
Source: here
sudo fsck.ext4 /dev/sda3 [-p|-a]
sau
e2fsck -f -v -y /dev/sda3
[aceasta comanda e utilizata de gparted, la aplicarea optiunii “Check”] (alte informatii aici si aici)
Se foloseste alt manager de retea (wicd, in cazul meu), iar firefox-ul interogheaza doar network-manager, nu si wicd, care il inlocuieste, si nu stie ca computerul este conectat la net (fie cu un modem USB, fie wireless / cablu / PPPoE).
se tasteaza ‘about:config‘ in address bar (se accepta indicatia firefox-ului de a nu ‘strica’ nimic), se cauta optiunea ‘toolkit.networkmanager.disable‘ (se poate folosi campul de filtrare) si se seteaza pe true. (kudos: openbala.com)
/sbin/ifconfig -a
sudo dhclient3 eth0 (wlan0)
sudo apt-get install wicd
I had the same problem with firefox 3.6.3 (not that the version matters…).
Este o eroare provenita de la fonturi instalate incorect sau cu drepturi de acces nepotrivite.
I tried some simple things:
So, the most simple solution was to delete all the fonts (as root):
cd /usr/share/fonts/truetype/msttcorefonts
rm -rf *
and reinstall them (as normal user):
sudo apt-get install msttcorefonts
here i ran into another smaller problem with a ttf font installer, so I had to do:
sudo apt-get remove ttf-mscorefonts-installer
sudo apt-get install msttcorefonts
Este o eroare provenita de la lipsa pachetului KTTSD (text-to-speech).
pachetul kttsd nu e instalat si apoi:
1. exista o instalare anterioara de KDE (sau un backup/restore) care lasa in urma directorul .kde ce contine setari care implica acest feature
2. ceasul analog/digital este setat sa spuna ora prin text-to-speech
1. cea mai simpla: instalati pachetul KTTSD si dependintele sale, cu un total de ~ 24 MB – daca nu aveti limita/penurie de spatiu;
2. cautati si stergeti directorul .kde din home de la o fosta instalare KDE care instalase pachete din gama Accesibility, sau dezactivati folosirea feature-ului text-to-speech din programele/utilitarele care ruleaza – mai multe detalii aici si aici.
Am incercat sa uploadez pe photobucket.com niste poze preluate de pe camera mea , iar uploader-ul lor nu vedea decat fisierele cu extensiile scrise cu litere mici (minuscule?!), asa ca a trebuit sa le modific..
In Dolphin (managerul de fisiere default din Kubuntu) nu se pot modifica numele de fisiere bulk, si nu aveam chef sa fac iar comparatii intre file-managere, asa ca am trecut in clasica linie de comanda si am rezolvat usor (bine, dupa 5 minute de incercari si la sfarsit apeland la man [rtfm!]):
Ubuntu 9.10 Karmic Koala has come out, and that means it’s time to explain how to do a basic Samba setup on the new version. All Terminal commands in this walkthrough are bolded, and USERNAME stands for your username on your Ubuntu system.
First, you’ll need to install Samba. Fire up a Terminal window and use this command:
sudo apt-get install samba
Follow the default prompts to install Samba. Now, Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you’ll need to create a Samba password for yourself with this command:
sudo smbpasswd -a USERNAME
(USERNAME, of course, is your actual username.)
Type a suitably strong password (make sure it includes uppercase, lowercase, punctuation, and numbers). Once your password is created, the next step is to edit your /etc/samba/smb.conf file, the configuration file for Samba. Begin by creating a folder named ‘test’ on your home folder; we’ll use that for our test shared folder (you can create other shared folders using the same method):
mkdir /home/USERNAME/test
Next, make a safe backup copy of the original smb.conf file to your home folder, in case you make an error:
sudo cp /etc/samba/smb.conf ~
Now use your text editor of choice to edit smb.conf:
sudo gedit /etc/samba/smb.conf
(New users will probably find gedit the easiest to use due to its GUI; but you can use emacs or vi just as readily, especially if you’re using the server version of Ubuntu, which doesn’t include X11 by default.)
Once smb.conf has loaded, add this to the very end of the file:
[test]
path = /home/USERNAME/test
available = yes
valid users = USERNAME
read only = no
browsable = yes
public = yes
writable = yes
(There should be no spaces between the lines, and note also that there should be a single space both before and after each of the equal signs.)
These settings will share the test folder we created earlier, and give your username and your username alone permission to read and write to the folder. Once you have input the changes, save smb.conf, exit the text editor, and restart Samba with this command:
sudo /etc/init.d/samba restart
Once Samba has restarted, use this command to check that your smb.conf doesn’t contain any syntax errors:
sudo testparm
If you pass the testparm command, Samba should be working; try accessing the shared folder from another computer on your LAN.
consola: konsole (pt KDE–Kubuntu) sau terminal (pt Gnome-Ubuntu) sudo apt-get install terminator (o consola ‘evoluata’ – [l]userii stiu de ce!)
vim (text editor), wicd (network manager – interactiv install), mc (file manager [text-mode]) or krusader sau gnome-commander (file-managers [graphic mode]), sun-java6-jre sun-java6-plugin sun-java6-fonts sun-java6-jdk (java – for netbeans++ – interactiv install), sshfs (mounts ssh locations as folders), cvs, hg (version control system), htop (process viewer), ailurus (ubuntu apps tweaker), synaptic (apps manager – graphical interface)