?
Solved

How to trace the Linux command rm

Posted on 2011-09-22
6
Medium Priority
?
361 Views
Last Modified: 2012-05-12
Would like to trace the command "rm" or "cp" as deep as possible. For example,
rm /usb/file.txt

Remove a file file.txt from USB stick.

What kind of operations are involved in this removal? As a user we know when we issue "rm", the file will be removed. OS kernel takes care of that.
Can any gurus shed some light on how the kernel does it, any code for it, or any links talking about it?
0
Comment
Question by:jl66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 21

Assisted Solution

by:Papertrip
Papertrip earned 960 total points
ID: 36583437
strace rm /usb/file.txt

Open in new window

0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 1040 total points
ID: 36583729
You can add -v to strace for verbose output or use ltrace -S to trace system and library calls::

strace -v rm /usb/file.txt

Open in new window

or
ltrace -S rm /usb/file.txt

Open in new window

0
 

Author Comment

by:jl66
ID: 36583977
Thanks for both of you. I will test them and get back to you.
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 

Author Comment

by:jl66
ID: 36585078
I ran the commands and got the following outputs:

...
SYS_brk(NULL)                                                      = 0x9128000
SYS_access(0x529ec6, 4, 0x52ffc4, 0x530660, 0x529ec6)              = -2
SYS_open("/etc/ld.so.cache", 0, 00)                                = 3
SYS_fstat64(3, 0xbfc53d84, 0x52ffc4, 0x5305e8, 3)                  = 0
SYS_mmap2(0, 90150, 1, 2, 3)                                       = 0xb7856000
SYS_close(3)                                                       = 0
SYS_open("/lib/libc.so.6", 0, 00)                                  = 3
SYS_read(3, "\177ELF\001\001\001", 512)                            = 512
SYS_fstat64(3, 0xbfc53dc8, 0x52ffc4, 0xb7869210, 0x8057cd4)        = 0
SYS_mmap2(0, 4096, 3, 34, -1)                                      = 0xb7855000
SYS_mmap2(0x533000, 0x16f928, 5, 2050, 3)                          = 0x533000
SYS_mmap2(0x69d000, 12288, 3, 2066, 3)                             = 0x69d000
SYS_mmap2(0x6a0000, 10536, 3, 50, -1)                              = 0x6a0000
SYS_close(3)                                                       = 0
SYS_mmap2(0, 4096, 3, 34, -1)      
....

Could you please tell me those functions belong to which *.cpp or *.h? Is thtere any way to show the info too?
 
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 36588645
Well, I guess you'd have to start digging in the Linux source code. I'm no expert at that, sorry.
0
 

Author Closing Comment

by:jl66
ID: 36713558
Thanks a lot.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question