Jump to content
xisto Community

dserban

Members
  • Content Count

    282
  • Joined

  • Last visited

Everything posted by dserban

  1. Quick overview of bash As mentioned in this forum before, bash is the most popular shell environment in the Linux world, and a good tutorial can be found here: http://www.tldp.org/LDP/abs/html/ The purpose of this topic is to show you a couple of quick how-to nuggets that I'm deriving from personal experience, both from using bash inside of Linux itself, as well as from using cygwin, a Win32 port of a bunch of Linux utilities, which includes bash as one of the shell options for running commands in. All examples have been made using cygwin in a Windows environment. Instalment 1: - How to convert all file names in a directory from mixed (or upper) case to lower case: Suppose we have a couple of files in our ztmptmp directory, like this: # pwd/cygdrive/c/ztmptmp## ls -ltotal 7488-rw-r--r-- 1 Administ Administ 1571302 Jun 6 14:55 02-DeFrag-xvid.avi-rw-r--r-- 1 Administ Administ 3431522 Jun 6 14:57 03-ResizeNTFS-xvid.avi-rw-r--r-- 1 Administ Administ 2649526 Jun 6 14:59 04-MakeLnxparts-xvid.avi-rw-r--r-- 1 Administ Administ 13292 Jul 1 17:56 AVSCAN-20070701-164946-8E31AAB2.LOG# and we throw another one in, for good measure: # touch IN.ALL.UPPER.CASE.TXT## ls -ltotal 7488-rw-r--r-- 1 Administ Administ 1571302 Jun 6 14:55 02-DeFrag-xvid.avi-rw-r--r-- 1 Administ Administ 3431522 Jun 6 14:57 03-ResizeNTFS-xvid.avi-rw-r--r-- 1 Administ Administ 2649526 Jun 6 14:59 04-MakeLnxparts-xvid.avi-rw-r--r-- 1 Administ Administ 13292 Jul 1 17:56 AVSCAN-20070701-164946-8E31AAB2.LOG-rw-r--r-- 1 Administ Administ 0 Jul 1 18:45 IN.ALL.UPPER.CASE.TXT# The script that converts the file names to lower case looks like this: > done # linenums:0'># for myfile in *> do> mv $myfile `echo $myfile | tr 'A-Z' 'a-z'`> done# and the result is the one I expected: # ls -ltotal 7488-rw-r--r-- 1 Administ Administ 1571302 Jun 6 14:55 02-defrag-xvid.avi-rw-r--r-- 1 Administ Administ 3431522 Jun 6 14:57 03-resizentfs-xvid.avi-rw-r--r-- 1 Administ Administ 2649526 Jun 6 14:59 04-makelnxparts-xvid.avi-rw-r--r-- 1 Administ Administ 13292 Jul 1 17:56 avscan-20070701-164946-8e31aab2.log-rw-r--r-- 1 Administ Administ 0 Jul 1 18:45 in.all.upper.case.txt# Advanced UNIX / Linux users already know what did the trick, but for completeness I am giving a detailed explanation. When you run the script, the first thing that happens is that the shell sees the wildcard * and expands it into the full list of files, in other words, bash temporarily (and internally) changes the script to look like: done linenums:0'>for myfile in 02-DeFrag-xvid.avi 03-ResizeNTFS-xvid.avi 04-MakeLnxparts-xvid.avi AVSCAN-20070701-164946-8E31AAB2.LOG IN.ALL.UPPER.CASE.TXTdomv $myfile `echo $myfile | tr 'A-Z' 'a-z'`done Each of the file names in that list is then in turn subject to the mv command. mv is a pretty basic command that can be used to move or rename a file. In this case, we are supplying a target file name as the second argument and not a directory, so it will know to perform a rename operation. The two arguments of the mv command are: - $myfile - `echo $myfile | tr 'A-Z' 'a-z'` Note the use of backticks with which we surround the Linux command: echo $myfile | tr 'A-Z' 'a-z' These backticks instruct the bash shell to run the command inside and substitute its output for the entire string (including the backticks). To understand what the command does, let's test it using the first file name: 02-defrag-xvid.avi # linenums:0'># echo 02-DeFrag-xvid.avi | tr 'A-Z' 'a-z'02-defrag-xvid.avi# Here, the output from the first command, which is simply the literal string 02-DeFrag-xvid.avi is fed to the second command as the input. The tr command expands the character sequences A-Z and a-z into the full-blown ASCII sequences: ABCD ... Z and abcd ... z then makes a positional translation of the text it receives as its input (in our case the file name), therefore the name tr for translate. So it will loop through each character of the file name and go: Is this character an A? if yes, replace the A with the character in the same position from the second string, which is a lowercase a. If no, move on to the second position. Is this character a B? ... you get the idea... until it exhausts the input string, at which time it will output the modified string. And the modified string will replace the backticks and become the second argument to the mv command, as explained above.
  2. I would like to add to that:- If at all possible, and if you don't plan to advertise your services to the whole world, do not run them on well-known ports."Security by obscurity", so to speak.Configure your FTP server to listen to e.g. port 7777 instead of 21, give Apache a port number of 9595, etc.I was recently hacked by a random person through a string of bad decisions and negligence on my part.I had configured my desktop PC to work as the default DMZ server, in other words, the one host that by default receives all port forwarding requests for port numbers greater than 1024. I had done that a while ago and this detail had slipped my mind.Then one day I installed VMWare Player on my desktop and was playing around with a virtual live Knoppix environment.The VMX file I had downloaded from somewhere was configured to allow remote VNC access on port 5900 with no password.So far so good, but apparently there are hackers who port scan ranges of IP addresses just with port 5900, so I learned my lesson now and I treat 5900 as a well-known port.So anyway, I was typing away at the root shell in my virtual Knoppix environment when suddenly I start noticing some strange behavior: random characters being output in the shell window, obscure Knoppix configuration applets popping up for no apparent reason, etc.First I thought it must be a bug in the VMWare player, maybe because my PC was running low on memory, but then I saw something else: this person pasted into my root shell a very well conceived ftp script the purpose of which was to connect to a site with a user name and password and download a .exe file into the WINDOWS directory.The name of the file was honeypot.exe or pothon.exe or something along those lines.Obviously, the script failed miserably because the Knoppix ftp utility does not understand the same switches as its Windows couterpart, but I was curious whether or not the username and password for that site were a valid combination ... and they were!In the end, I got a good laugh out of it, because I imagine this must have been a script kiddie who had not seen a Linux command prompt in his entire life, and even if he had, he couln't have caused any permanent damage to my environment, seen as the Knoppix iso file is handled in read-only mode by VMWare player.But this small incident served to remind me that the threat from hackers who do this stuff for fun or in order to have something to brag about in their obscure black hat forums ... is REAL.It also served to make me a little bit more paranoid and check three things at least once a day:- what processes are running on my PC? Do I know what each one of them does?- what ports are open on my PC, which ones have established connections with a remote host, and which applications have opened those ports?- what are the attached devices on my wireless router? Has anyone managed to break the three layers of security (WPA, strong password, MAC filtering)?
  3. Hi toofast, I have a couple of suggestions for how make your tutorials more readable / useful. First of all, assume that your readers will not already know what the software you are describing can be used for. For example, even after visiting http://www.psybnc.at/ I still don't know what this piece of software is meant for. I can already tell by your description that it is some kind of server software because you talk about configuring a listening port. I can also tell that it has something to do with IRC. So I'm taking a wild guess - it's an IRC server. So, begin your tutorials with a high level overview of the software's capabilities and do not let the readers of your tutorials second guess basic stuff about the software.
  4. Super!It works.I tried the approach that wutske suggested, because it is more attuned to what I am trying to accomplish, but many thanks to both of you for putting in the effort to answer my question.
  5. I just discovered the command "route print", so I am posting below the "before" and "after" snapshots:- Before enabling the embedded NIC (Internet up): ===========================================================================Interface List0x1 ........................... MS TCP Loopback interface0x10003 ...00 14 d1 c1 42 c5 ...... 802.11g Wireless Network Adapter - Packet Scheduler Miniport======================================================================================================================================================Active Routes:Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.2 25 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 192.168.1.0 255.255.255.0 192.168.1.2 192.168.1.2 25 192.168.1.2 255.255.255.255 127.0.0.1 127.0.0.1 25 192.168.1.255 255.255.255.255 192.168.1.2 192.168.1.2 25 224.0.0.0 240.0.0.0 192.168.1.2 192.168.1.2 25 255.255.255.255 255.255.255.255 192.168.1.2 192.168.1.2 1Default Gateway: 192.168.1.1===========================================================================Persistent Routes: None - After enabling the embedded NIC (Internet down): ===========================================================================Interface List0x1 ........................... MS TCP Loopback interface0x10003 ...00 14 d1 c1 42 c5 ...... 802.11g Wireless Network Adapter - Packet Scheduler Miniport0x10004 ...00 30 05 45 15 5a ...... IntelĀ® PRO/100 VE Network Connection - Packet Scheduler Miniport======================================================================================================================================================Active Routes:Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.2 25 0.0.0.0 0.0.0.0 192.168.2.2 192.168.2.2 20 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 192.168.1.0 255.255.255.0 192.168.1.2 192.168.1.2 25 192.168.1.2 255.255.255.255 127.0.0.1 127.0.0.1 25 192.168.1.255 255.255.255.255 192.168.1.2 192.168.1.2 25 192.168.2.0 255.255.255.0 192.168.2.2 192.168.2.2 20 192.168.2.2 255.255.255.255 127.0.0.1 127.0.0.1 20 192.168.2.255 255.255.255.255 192.168.2.2 192.168.2.2 20 224.0.0.0 240.0.0.0 192.168.1.2 192.168.1.2 25 224.0.0.0 240.0.0.0 192.168.2.2 192.168.2.2 20 255.255.255.255 255.255.255.255 192.168.1.2 192.168.1.2 1 255.255.255.255 255.255.255.255 192.168.2.2 192.168.2.2 1Default Gateway: 192.168.2.2===========================================================================Persistent Routes: None
  6. Here's my setup:My PC connects to my Internet facing wireless router via a USB-pluggable wireless NIC, the IP address of which is 192.168.1.2 (netmask 255.255.255.0).The IP address of my router's LAN port is 192.168.1.1.The NIC which is embedded in the motherboard has remained disabled so far.Everything works OK, but I recently got a hold of a crossover cable, and I started using it to connect a laptop to my PC.So I enabled the embedded NIC on the PC and gave it an IP address of 192.168.2.2 (netmask 255.255.255.0, default gateway 192.168.2.2).The laptop's IP address is 192.168.2.1.My only objective is to able to exchange files between my PC and my laptop.I do not want to connect my laptop to the internet, either directly or indirectly.And here comes my problem:After setting up the (crossover cable) connection between the two, I tried going out to the internet again on my PC, and failed.I tried using tracert to troubleshoot what's going on, and my gut feeling is that as soon as I enabled the embedded NIC on the PC, it seems to think "Oh, this is my new Internet, let me send all the requests from the browser to this new default gateway 192.168.2.2".One solution that comes to my mind is to use static routes. I know what they are in theory, but I don't know how to issue the commands.If anyone has experience using static routes in Windows XP, I would appreciate a few pointers in the right direction.Also, if there is a better / more efficient / more elegant solution, I would very much like to hear it.
  7. I'm not sure why this happens, but putting that output in a code box cuts it off.Here is the same output without a code box:
  8. Here it is, I finally got around to it. Resource Device I/O Port 0x00000000-0x00000CF7 PCI bus I/O Port 0x00000000-0x00000CF7 Direct memory access controller I/O Port 0x000003C0-0x000003DF VIA Tech CPU to AGP Controller I/O Port 0x000003C0-0x000003DF RADEON 9550 IRQ 21 VIA Rev 5 or later USB Universal Host Controller IRQ 21 VIA Rev 5 or later USB Universal Host Controller IRQ 10 RAID Controller IRQ 10 Universal Serial Bus (USB) Controller IRQ 9 Microsoft ACPI-Compliant System IRQ 9 SCSI/RAID Host Controller IRQ 16 RADEON 9550 IRQ 16 VIA Rev 5 or later USB Universal Host Controller IRQ 17 Creative AudioPCI (ES1371,ES1373) (WDM) IRQ 17 VIA Rev 5 or later USB Universal Host Controller IRQ 18 CMI8738/C3DX PCI Audio Device IRQ 18 Realtek RTL8139 Family PCI Fast Ethernet NIC Memory Address 0xA0000-0xBFFFF PCI bus Memory Address 0xA0000-0xBFFFF VIA Tech CPU to AGP Controller Memory Address 0xA0000-0xBFFFF RADEON 9550 I/O Port 0x000003B0-0x000003BB VIA Tech CPU to AGP Controller I/O Port 0x000003B0-0x000003BB RADEON 9550
  9. Can I use YouTube's FLV player on my site in combination with a FLV video that isn't stored on YouTube?Are there any legal implications when doing that?Has anyone done this before and can share their experience?I personally couldn't figure out by viewing the page source where the FLV player is located and how it's invoked.Any ideas?
  10. http://www.789mb.com/rg-erdr.php?_rpo=t is a non-starter. It has a 10MB limit on the file size.
  11. You can tell whether or not a link is a hot link by right-clicking on it, selecting "Save Target As ..." and looking at the file name it's placing in the subsequent dialog box by default. Suppose the link is something along the lines of: http://forums.xisto.com/no_longer_exists/ If the name it's trying to save it under is file.pdf, and you download it and you can look at it in Acrobat Reader, that link is a hot link. The best example of a link that looks deceivingly like a hot link but isn't one is a RapidShare link. Behind an URL like http://forums.xisto.com/no_longer_exists/ there is actually a server side script (probably written in PHP) that makes you jump through several more hoops before finally revealing to you - and redirecting your browser to - the real location of the file.
  12. I've tried using nslookup on the host name you specified, but my DNS server says it "can't find ftp.mediyama.astahost.com: Non-existent domain".I don't have a problem on my subdomain though.astahost subdomains should be working right away, so you will probably need to wait until Monday to get help from the admins.
  13. The PC has 512 MB of RAM, an AMD Athlon processor at 1.54 GHz and runs decently while in normal operation.If I had a dollar for each time I installed XP from scratch on this guy's PC with no effect on the boot problem I would ... fill a tank of gas.I looked at the motherboard and it looks intact to my untrained eye (no blown capacitors).I will try booting Knoppix as the next step, and if it's a motherboard problem, I will point him to this thread.The only problem with Knoppix though, is that I wouldn't be comparing apples to apples (XP booting from a fast HDD vs. Knoppix booting from a relatively slow CD/DVD drive), but I'll try it anyway.
  14. skaffers.com has a file hosting feature that supports hot linking.
  15. The question is based on a personal experience uploading a video in FLV format, which is the very format in which videos are stored on YouTube.So the original video was in avi format and it was crisp, I converted it to FLV and it also looked very good, but then I uploaded the FLV to YouTube and you can barely recognize it.
  16. There is a very good, free of charge / free of copyright restrictions video tutorial about this that you can download either directly or via torrent software.I have it on my PC but I forgot where I got it from. A quick Google search didn't help either.I'll keep looking, if I come across the link to the torrent file I will post the link here.
  17. Active mode is the legacy way of doing things. It is the way the FTP protocol was designed to work way back when the Internet was a small, friendly community of scientists, students, etc. Nobody called it active mode in those days because there was nothing to compare and contrast it with. Passive mode was designed later as an alternative, when hackers became a real and constant threat. The only advantage of active mode that I can think of is backwards compatibility. For example, if a large corporation runs a big old mainframe with an FTP server that doesn't do passive mode and only needs to be available to FTP clients on the intranet. I recently installed the FileZilla FTP server on my PC and, in order to get it to work, I not only had to forward the ports / port ranges for the control and data connections in order to get it to work in passive mode, but I also had to make my PC the default DMZ server in the router configuration, which now could make my PC somewhat more vulnerable, if I'm not careful. So that would be another advantage of active mode - less vulnerability on the server side.
  18. The short answer is yes. Knoppix may run from a CD, which is a read-only media, but your home directory will live in a RAM disk, which is just like any other disk as far as allowing you to store files, the only difference being that storage will happen in a specially designated section of memory instead of spinning magnetic media. For example, you can install Adobe Flash Player in Firefox, then configure your Konqueror to recognize and use the same plug-in, which will be stored in your home directory on RAM disk.
  19. I have a friend whose WinXP PC takes around 5-6 minutes to boot, whereas all other PCs I've seen take 1 minute give or take.Mine boots in 30 seconds.So this friend asked for my help and it turns out that this PC was made in someone's garage from components which obviously hadn't been tested for compatibility.The way it's behaving is that after the logo / progress bar has finished doing its thing, the screen turns black and stays black for about 3-4 minutes, then eventually you get to the welcome screen and so on.I have a hunch that the boot process is trying to configure some piece of hardware which isn't really needed and it makes a preset number of attempts before finally giving up and turning it over to the desktop.We tried removing all non-essential hardware (webcam, SanDisk card reader) but it's still booting slowly.I would at least like to be able to tell this friend why his PC is booting so slowly, even if there's nothing we can do about it.
  20. Be careful about extra line-feeds between your <td> and </td> tags. They produce unpredictable results. That's why I removed them from your example.
  21. <table width="489" border="1"><tr width="498"> <td width="249">test</td> <td width="249">test</td></tr><tr width="498"> <td width="498" colspan="2">test</td></tr><tr width="498"> <td width="249">test</td> <td width="249">test</td></tr></table>
  22. What is the best method for pinpointing the component of the Windows XP boot process which is the most time-consuming?
  23. I would like to add to that list:- Know exactly what processes need to be running on your PC by their technical names.- While you work, check that list every so often with the process viewer of your choice (I like Process Explorer since it shows who the software vendor is for each process)- Question the legitimacy of every new entry.- When in doubt, start your antivirus software and select the option to scan active processes.
  24. Please copy/paste your /etc/apt/sources.list here.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.