Difference between revisions of "User:Girts:Linux Notes"
(→How to mount CIFS file system) |
|||
(14 intermediate revisions by 2 users not shown) | |||
Line 27: | Line 27: | ||
== How to mount CIFS file system == |
== How to mount CIFS file system == |
||
<pre> |
|||
⚫ | |||
sudo mkdir -p /mnt/dest-dir |
|||
⚫ | |||
</pre> |
|||
== How to convert RPM package to DEB package == |
== How to convert RPM package to DEB package == |
||
Line 34: | Line 37: | ||
sudo alien -k name-of-rpm-file.rpm |
sudo alien -k name-of-rpm-file.rpm |
||
</pre> |
</pre> |
||
== How to find UUIDs of partitions == |
|||
<pre> |
|||
ls -l /dev/disk/by-uuid |
|||
</pre> |
|||
== How to synchronize two local folders == |
|||
<pre> |
|||
rsync -vap --delete /src/folder /dst/folder |
|||
</pre> |
|||
--delete means "delete files on destination, which are deleted on source". -p means "preserve original permissions". |
|||
Do not specify last source folder in destination! Example: |
|||
to sync /home/girts/Pictures to /mnt/backup/Pictures: |
|||
<pre> |
|||
rsync -va --delete /home/girts/Pictures /mnt/backup |
|||
</pre> |
|||
== How to copy files using hard links == |
|||
Thic command is useful for making incremental backups: first copy old files and then sync (using rsync) the new files to newly created directory having hard links to old files. |
|||
<pre> |
|||
cd source-dir |
|||
find * | cpio -dplm dst-dir |
|||
</pre> |
|||
dst-dir should be outside of src-dir |
|||
== How to convert movie audio track from AC3 to MP3 == |
|||
To convert audio track to MP3 192kbps and leave the video track without modification: |
|||
<pre> |
|||
sudo apt-get install libavcodec-unstripped-52 ffmpeg |
|||
ffmpeg -i input-file.avi -vcodec copy -acodec libmp3lame -ab 192000 output-file.avi |
|||
</pre> |
|||
Note: libavcodec-unstripped-x may have version number other than 52. |
|||
Input file may have any other audio format as well, it is not restricted to AC3 to MP3 conversion. |
|||
== How to kill all processes by name == |
|||
<pre> |
|||
ps fax | grep <name> | awk '{ print $1 }' | xargs kill -9 |
|||
</pre> |
|||
where: |
|||
* ps: lists all running processes |
|||
* grep: takes only lines containing required name |
|||
* awk: takes the first column of grep output (the process number) |
|||
* xargs: takes the process id and calls kill with it as argument |
|||
* kill - kills the process. "-9" means "send signal 9 (SIG_KILL)" |
|||
Here is another way: |
|||
apt-get install procps |
|||
pkill [-<signal>] <name> |
|||
There is also <code>pgrep</code>. |
|||
--[[User:Atis|Atis]] 13:45, 17 September 2009 (EEST) |
|||
== How to fix Subversion 'This client is too old to work with working copy' bug == |
|||
Run [[change-svn-wc-format.py]] in your working copy directory: |
|||
<pre> |
|||
change-svn-wc-format.py . 1.4 |
|||
</pre> |
|||
where 1.4 must be replaced with version of your svn client. |
|||
== How to remove .svn directories recursively == |
|||
find . -name .svn -print0 | xargs -0 rm -rf |
|||
Original idea from [http://codesnippets.joyent.com/posts/show/104 CodeSnippets] |
Latest revision as of 14:40, 8 May 2011
Contents
- 1 How to mount SSH file system in Ubuntu
- 2 How to run script over SSH and keep it running after SSH is closed
- 3 How to change timezone
- 4 How to mount CIFS file system
- 5 How to convert RPM package to DEB package
- 6 How to find UUIDs of partitions
- 7 How to synchronize two local folders
- 8 How to copy files using hard links
- 9 How to convert movie audio track from AC3 to MP3
- 10 How to kill all processes by name
- 11 How to fix Subversion 'This client is too old to work with working copy' bug
- 12 How to remove .svn directories recursively
How to mount SSH file system in Ubuntu
From this site.
To mount remote director /home/share from host example.com to local folder /mnt/share, using ssh user remuser and local user locuser:
sudo apt-get install sshfs sudo mkdir /media/share sudo chown locuser /media/share # local user must belong to the fuse group sudo adduser locuser fuse sshfs remuser@example.com:/home/share /media/share
Enter ssh user password when asked.
How to run script over SSH and keep it running after SSH is closed
- SSH into the host
- run
screen <your-script>
- detach screen by pressing Ctrl+A Ctrl+D
- you can close the SSH session and the script will remain running
- to return to screen session afterward, issue
screen -r
How to change timezone
sudo dpkg-reconfigure tzdata
How to mount CIFS file system
sudo mkdir -p /mnt/dest-dir sudo mount -t smbfs //192.168.0.1/shareName /mnt/dest-dir -ousername=remoteuser
How to convert RPM package to DEB package
sudo apt-get install alien sudo alien -k name-of-rpm-file.rpm
How to find UUIDs of partitions
ls -l /dev/disk/by-uuid
How to synchronize two local folders
rsync -vap --delete /src/folder /dst/folder
--delete means "delete files on destination, which are deleted on source". -p means "preserve original permissions". Do not specify last source folder in destination! Example: to sync /home/girts/Pictures to /mnt/backup/Pictures:
rsync -va --delete /home/girts/Pictures /mnt/backup
How to copy files using hard links
Thic command is useful for making incremental backups: first copy old files and then sync (using rsync) the new files to newly created directory having hard links to old files.
cd source-dir find * | cpio -dplm dst-dir
dst-dir should be outside of src-dir
How to convert movie audio track from AC3 to MP3
To convert audio track to MP3 192kbps and leave the video track without modification:
sudo apt-get install libavcodec-unstripped-52 ffmpeg ffmpeg -i input-file.avi -vcodec copy -acodec libmp3lame -ab 192000 output-file.avi
Note: libavcodec-unstripped-x may have version number other than 52.
Input file may have any other audio format as well, it is not restricted to AC3 to MP3 conversion.
How to kill all processes by name
ps fax | grep <name> | awk '{ print $1 }' | xargs kill -9
where:
- ps: lists all running processes
- grep: takes only lines containing required name
- awk: takes the first column of grep output (the process number)
- xargs: takes the process id and calls kill with it as argument
- kill - kills the process. "-9" means "send signal 9 (SIG_KILL)"
Here is another way:
apt-get install procps pkill [-<signal>] <name>
There is also pgrep
.
--Atis 13:45, 17 September 2009 (EEST)
How to fix Subversion 'This client is too old to work with working copy' bug
Run change-svn-wc-format.py in your working copy directory:
change-svn-wc-format.py . 1.4
where 1.4 must be replaced with version of your svn client.
How to remove .svn directories recursively
find . -name .svn -print0 | xargs -0 rm -rf
Original idea from CodeSnippets