Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jan 252010
 

Create a temp file in Linux

Answer:

To create a temp file in Linux, you can use the mktemp command

E.g.

# mktemp foo.XXXXXXXXXXX

foo.aAIYdsa5027

mktemp will replace XXXXX... by random characters and create that temp file for you.

Jan 242010
 

Serve current directory using HTTP with a single command

Answer:

Sometimes, you want to share some files in a given directory in your Linux system to other people, you might consider setup a NFS, Samba, FTP or so.

However, the easiest method is to export the directory using HTTP, with the help of Python.

E.g.

 # cd /data/
python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

Now people can access the web server at port 8000 of your system's IP address, to access the /data directory.

Jan 232010
 

Using system directory stack with pushd & popd

Answer:

When you need to changes a lot of directory frequently, pushd & popd can be very useful

E.g.

john@localhost:/tmp $ pushd /home/jack/ 
# change to /home/jack/ and push to the stack
/home/jack /tmp

john@localhost:/home/jack $ pushd /home/mark/  
# change to /home/mark/ and push to the stack
/home/mark /home/jack /tmp

john@localhost:/home/mark $ popd  
# pop current directory and change to /home/jack
/home/jack /tmp

john@localhost:/home/jack $ popd  
# pop current directory and change to /tmp
john@localhost:/tmp/ $